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

2013/7/4

(no title)

fredold44 fredold44

2013/7/4

#
i need help making a image witch says GAME OVER (witch i already have) come up when you get eaten, i'm new to this and i have no idea.
Gevater_Tod4711 Gevater_Tod4711

2013/7/4

#
If you already got the image you just need to check whether you get eaten and then display the image. To display the image just use this:
//if (gotEaten) 
World world = getWorld();
if (world != null) {
    world.removeObjects(world.getObjects(null));//remove all objects in the world;
    world.getBackground().drawImage(new GreenfootImage("gameOverImage.png"), 0, 0);//draw the game over onto the worlds background;
    Greenfoot.stop();//stop the game;
}
This will only work if your actor is not already removed from the world. To show you how you can do this it would be great to know the code you're using. Especally the parts where the actor gets eaten.
fredold44 fredold44

2013/7/4

#
thank you
fredold44 fredold44

2013/7/4

#
if(isTouching(turtle.class) ) { removeTouching (turtle.class); Greenfoot.playSound("au!.wav"); Greenfoot.playSound("gameover.wav"); } sorry, i didn't describe my problem well, the bird doesn't actually eat the turtle he removes it. This ^ all works but how do i make the game over image occupy the whole screen and the actors disappear.
fredold44 fredold44

2013/7/4

#
i probably sound pretty stupid not knowing these simple things. by the way how old are you??
Gevater_Tod4711 Gevater_Tod4711

2013/7/4

#
If you just start programming it's normal not to know such things. I'm 17. To your problem: Your probably executed the code at the wrong place. If you put the code I gave you before abouve 'removeTouching(turtle.class);' it should work.
fredold44 fredold44

2013/7/6

#
thanks a lot, by the way i'm 11
You need to login to post a reply.