This site requires JavaScript, please enable it in your browser!
Greenfoot back
irmina_pablico
irmina_pablico wrote ...

2017/3/15

WHEN OBJECTS FALLS ON THE GROUND HOW CAN I DO AND " END/GAME OVER" ?

irmina_pablico irmina_pablico

2017/3/15

#
Our game consist of balloons with letters on them. If you press the corresponding letter on the balloon the balloon will disappear. Our group wanted to ask how to put or end the game if the player failed to press the corresponding letter letting the balloon "fall" to the ground ! Please help hehe thank you !
danpost danpost

2017/3/15

#
A falling actor reaches the ground when its y-coordinate value becomes one less than the height of the world it resides in. So, that is what you check for in the act method of the class of the actor:
if (getY() == getWorld().getHeight()-1)
{
    // some end-game/game-over code goes here
}
Whether you add an actor and stop the scenario or change the world to show the end game state is up to you. Place the code where indicated.
You need to login to post a reply.