Destroying actor when it is out of screen

Crank1dCrank1d Member Posts: 8
edited November -1 in Working with GS (Mac)
How to do that? Ive tried with invisible walls with collision but it wasnt the best solution.

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Create a rule with these rules, and make sure it says ANY

    when self.position.x is < 0
    when self.position.x is > 480
    when self.position.y is < 0
    when self.position.y is > 320

    destroy actor

    If the actor 's position moves offscreen it will get destroyed, this is for a landscape orientation.
  • Crank1dCrank1d Member Posts: 8
    Thanks! :)
  • ApplaudAppsApplaudApps Member Posts: 308
    You might need to tweak the parameters in jon's example.

    For example if your actor is 100 x 100 pixels it won't be fully off screen until its position has gone 50 pixels beyond the boundaries so you would need :

    when self.position.x is < -50
    when self.position.x is > 530
    when self.position.y is < -50
    when self.position.y is > 370
  • ShaneS429ShaneS429 Member Posts: 77
    a more universal method that would work regardless of the actor or scene size would be...

    Destroy if:
    Self.Position.X < -(Self.Size.Width/2)
    Self.Position.X > (Game.Display.Size.Width) + (Self.Size.Width/2)
    Self.Position.Y < -(Self.Size.Height/2)
    Self.Position.Y > (Game.Display.Size.Height) + (Self.Size.Height/2)
Sign In or Register to comment.