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

2013/9/24

Multiple Objects

alagon alagon

2013/9/24

#
In my code i have said to add a game over screen once it hits the world border. There are multiple things that touch the screen and they all initialise the game over screen. How would I make the game only add 1 game over screen? The Basic code:
getWorld().addObject(new BombGameOver(), 500,200);


// The Bomb Class only has movement and its animations, The Game Over screen only has its location and its countdown. 
danpost danpost

2013/9/24

#
if (getWorld().getObjects(BombGameOver.class).isEmpty()) getWorld().addObject(new BombGameOver(), 500, 200);
or use 'Greenfoot.stop();' after your code above (but then it would not count down, would it).
alagon alagon

2013/9/24

#
Thank you for the quick response! It worked! Thank you!
You need to login to post a reply.