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

2015/3/24

Buttons To Play Again

drchrisv1 drchrisv1

2015/3/24

#
I would like to add a button to the end of my "Space Invaders" game that gives the user the option of playing again or otherwise making use of Greenfoot.stop();
Srax Srax

2015/3/24

#
You can do as, if the actor dies/disappear from the world, it switches back to the start screen, or just start over, is that what you want to do?
danpost danpost

2015/3/24

#
What do you want displayed while the button is on the screen? Any game actors would have to be programmatically 'paused' if in the world. Maybe a 'GameOver' world would be useful to display the final score and provide the restart (play again) button. Just have the button start a new game world when clicked on.
drchrisv1 drchrisv1

2015/3/24

#
@Srax, Yes, I would like the user to have a choice between starting over, (and then it should have the same effect as when you press the "Run" button for the first time) or pressing no, and then i could just bring up a new actor that is simply an image. @danpost I have told Greenfoot to display a "You Win" or "Game Over" image according to whether or not the user has completed the wave. Like you said in your last sentence, "Just have the button start a new game world when clicked on." I do not know how to tell Greenfoot that it must rerun all the code if (for instance) "Yes" is clicked.
danpost danpost

2015/3/24

#
If "Yes" is clicked, execute the line:
1
Greenfoot.setWorld(new GameWorldName());
where 'GameWorldName' is the name of your game world.
Super_Hippo Super_Hippo

2015/3/24

#
Usually you can simply use 'Greenfoot.setWorld(new NameOfYourWorld());' to restart. Make sure to reset all static variables in the constructor if you use any.
Srax Srax

2015/3/25

#
Are you still in need of help?
drchrisv1 drchrisv1

2015/3/25

#
@danpost , @Super_Hippo and @Srax , thank you all very much... To be honest I didn't think that I would get any response since there are so many questions posted daily. I am glad that i was proved wrong :) so Thank you
You need to login to post a reply.