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

2012/4/22

how to make menu in the beginning of the game?

snow13 snow13

2012/4/22

#
such as new game, instruction and so on.. can anyone teach me?
danpost danpost

2012/4/22

#
I would first create a (new sub-class extending actor) 'Panel' class that would be an object that covers the whole scenario window (this will prevent any unneccessary interaction while the menu is active; it can be transparent or a flat color or an image ). You can drawImages (text and/or title images) onto the panel. Then create a (new sub-class extending actor) 'Button' class that recieves the text in the constructor to display on the buttons created. The 'Button' class should have an object variable (private String textString = "";) to hold the text that it displays. The 'Button' class should also have a 'Button class' variable (public static String selected = "";). In the 'Button' class act() method, say that if button is clicked on, set 'selected' to 'textString'. In the world class act() method (or a method that it calls each act cycle) say that if Panel.class object is in world and 'selected' in 'Button' class is not "", then act on what 'selected' contains and remove Panel and Buttons. During creation of Panel and Buttons, make sure to clear 'selected' in the Button class to "" or it will still contain the last selection.
Builderboy2005 Builderboy2005

2012/4/22

#
Alternatively, it might be easier to create an entirely different world that you can switch into. This can make pausing a bit easier, since if you stayed in the same world, you would need methods in all the objects to support pausing.
You need to login to post a reply.