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

2017/4/27

End the Game

Chris80 Chris80

2017/4/27

#
I want to end the game after winning by one of the player. Game should end when Gameover box appears .
danpost danpost

2017/4/27

#
Chris80 wrote...
I want to end the game after winning by one of the player. Game should end when Gameover box appears .
Add a 'Greenfoot.stop();' statement immediately after having the Gameover box added into the world. You can also add the following method to your World subclass:
public void started()
{
    if (!getObjects(Gameover.class).isEmpty()) Greenfoot.stop();
}
This is so the user is not able to restart (unpause) the game.
You need to login to post a reply.