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

2011/11/26

Greenfoot.setWorld()

darkmist255 darkmist255

2011/11/26

#
So I'm FINALLY almost done my ping pong game (kinda fun too :D), and I want to make it so that a full screen image saying "defeated" shows up when you lose. Would Greenfoot.setWorld() to a new world with a new image be the best way to do this? If it is, how can I make a reference to LoseScreen.class? Because
            Greenfoot.setWorld(LoseScreen);
doesn't work and
            World losescreen = LoseScreen;
            Greenfoot.setWorld(losescreen);
doesn't either. I'm sure it's not that difficult, I just need to know the syntax for what I need to do. Thanks :D!
delmar delmar

2011/11/26

#
The setWorld method needs an object, not a class. So it needs to be Greenfoot.setWorld(new LoseScreen()); (and LoseScreen needs to be a subclass of World). However, an easier way is to make LoseScreen an actor, with an image that is the same size as the whole world, and just create one of those and put it into the world. Voilá.
darkmist255 darkmist255

2011/11/27

#
Ahaha, thanks, I forgot I needed to create a new one since there wasn't one there yet. If it doesn't work as a world I'll make it an actor. Thanks :D.
You need to login to post a reply.