Would someone be able to give me a code for a simple game over end screen once the character loses all of his lives or is taken away from the world


1 2 3 4 5 | if (characterDies()) { //only an example; World world = getWorld(); world.removeObjects(world.getObjects( null )); //removes all the objects in the world; world.addObject( new GameOverScreen(), world.getWidth()/ 2 , world.getHeight()/ 2 ); //adds the game over screen in the middle of the world; } |
1 2 3 4 | World world = getWorld(); if (world != null ) { world.removeObjects(world.getObjects( null )); } |
1 2 3 4 5 6 7 8 9 10 | Actor Rocket; Rocket = getOneObjectAtOffset( 0 , 0 ,Rocket. class ); if (Rocket != null ) { World world = getWorld(); world.removeObjects(world.getObjects( null )); } |
1 | world.addObject( new GameOver(), world.getWidth()/ 2 , world.getHeight()/ 2 ); |
1 2 | world.setBackground( "game_over.jpg" ); Greenfoot.stop(); |
1 2 3 4 5 6 7 8 | Actor Rocket; Rocket = getOneObjectAtOffset( 0 , 0 ,Rocket. class ); if (Rocket != null ) { World world = getWorld(); world.removeObjects(world.getObjects( null )); // here } |