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

2013/7/8

ending a game?

grace_lowton grace_lowton

2013/7/8

#
once my character has been 'eaten' by a randomly floating enemy i want the game to end on a sort of game over screen, how can i do this? thankyou in advance
You can make a GameOver world that will display a message (You can either draw it in a different program than load it, or use the GreenfootImage methods to draw it) or you can spawn an actor that displays the message for you.
grace_lowton grace_lowton

2013/7/8

#
okay, ill do that, and how do i make it appear?
You just have a method that would change worlds or make it. Then you call it when something happens (like run out of health, or it's eaten)
//Changing worlds
public void gameOver()
{
    Greenfoot.setWorld(new GameOverWorld());
}

//New actor by another actor specify x and y
public void gameOver()
{
    getWorld().addObject(new GameOverActor(),x,y);
}

//New actor from a world, specify x and y
public void gameOver()
{
    addObject(newGameOverActor(),x,y);
}
grace_lowton grace_lowton

2013/7/8

#
thankyou^_^
You need to login to post a reply.