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

2015/1/21

Score on Game over screen

gamer98 gamer98

2015/1/21

#
Hi ,How can i get my final score when number of lives = 0 to be displayed on the gameover screen.
danpost danpost

2015/1/21

#
There are multiple discussion threads dealing exactly with this issue. Usually, it is the case that they have something like this;
Greenfoot.setWorld(new GameOver());
and do not realize that they can split the line up to this:
GameOver gameover = new GameOver();
Greenfoot.setWorld(gameover);
By doing this, they can then proceed to call methods on the new game over world. For example:
gameover.addObject(...);
// or
GreenfootImage bg = gameover.getBackground();
// or if you added a method called 'setScore' to the game over world
gameover.setScore(score);
Optimal, however, would be to pass the score to the constructor of the game over world using something like this:
Greenfoot.setWorld(new GameOver(score));
You need to login to post a reply.