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

2013/7/27

Don't start the game until you click on an object

joeschmoe joeschmoe

2013/7/27

#
I want you to have to click the run botton but nothing actually starts until you click an object on the screen. I have the part to make the game start down: (I think :p ) public void CheckStart() { if(Greenfoot.mousePressed(this)) { Greenfoot.start(); } } But how can I stall the game until this happens?
danpost danpost

2013/7/27

#
The 'CheckStart' method you show above will not work at all. The program has to be in a running state for any mouse actions within it to be detected. So, trying to detect them while the program is stopped is futile. If you require the user to press the Run button, just remove the method and any calls to it.
davmac davmac

2013/7/27

#
Do you need anything else to be displayed at the same time as the button to start? If not, just have the button intiialise the rest of the actors etc when it is clicked. Otherwise, you need to have the actors check whether the scenario is running (according to your own criteria) before they do anything. For instance, you could have a variable in the world which is true if the scenario is running (your object has been clicked) or false if not.
You need to login to post a reply.