Count Off Screen Actors

I'm trying to create a way of counting when actors go off screen. the idea is when all surviving actors leave the screen the level is complete, any help here please?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    First, create an integer attribute called game.actorCount. In each actor that is on the screen or will spawn on the screen, add a behavior (not inside a rule) to change attribute game.actorCount to game.actorCount+1.

    Two ways to do this:

    (1) Place "wall" actors just outside of the scene boundaries and then use a rule that says When actor collides with [wall actor], change attribute game.actorCount to game.actorCount-1.

    (2) Check the position of the actors: When self.position.X > [scene width] + self.size.width/2, change attribute game.actorCount to game.actorCount-1, etc. for all four directions.

    Then, have a rule that says When attribute game.actorCount=0, [the level is complete]

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tom44410tom44410 Member Posts: 5

    that's perfect thank you! one more thing? is there a way of counting if actors have been destroyed?? i.e if you start this 10 and only 3 cross the line i still want it to move to the next level.

Sign In or Register to comment.