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();
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.
@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.
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.
@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