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

2012/4/13

Game Start Menu

theDoctor theDoctor

2012/4/13

#
I'm trying to make a start menu with instructions for a game I'm making, but I need it to display immediately when you hit "play" (in the Greenfoot menu), and then disappear when you press the space bar. I really have no clue how to go about this. I'm going to need some serious help!
rick rick

2012/4/13

#
First you should implement a class which displays the instructions, say a class named Display. The easiest way to do this is possibly to use a graphics tool to prepare an image resembling your start menu. Save it as a .png (or .jpg) file and pick this file as the image for the Display class. Now you can create a display, add it to the world and remove it. In order to achieve the effect you have in mind, I'd suggest that you implement a started() method (see Greenfoot documentation) in your World class where you just add a new Display to the world. In the Display's act() method the display can remove itself (i.e. getWorld().removeObject(this); ) after the space key is pressed. You will really want to wait until the space key is down, for example in a while loop (so called active wait). Otherwise the other actor's act methods will be called as well which means that your game will be run in the background while the display is on the screen :-)
theDoctor theDoctor

2012/4/16

#
Ok, I'll see if I can get this to work!
You need to login to post a reply.