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

2012/1/18

Resetting the entire game

Blight Blight

2012/1/18

#
Hi, I'm looking for a button that resets the entire world. Example: I press the exit button and my whole greenfoot project starts all over again. Thanks in advance.
davmac davmac

2012/1/19

#
How would this be different from the existing "reset" button? (Or are you looking for a way to do a reset programmatically?)
Blight Blight

2012/1/19

#
Yes, looking for a way to do a reset programmatically. ;)
davmac davmac

2012/1/19

#
Then: Greenfoot.setWorld(new MyWorld()); ... where 'MyWorld' is your world subclass - should do the trick!
Blight Blight

2012/1/19

#
Working, thanks!
J0SH1X J0SH1X

2016/2/19

#
wont work :( " import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * The screen when Link dies * @author Andrew Harmon * @version 5/10/2012 */ public class GameOverScreen extends UI { /** * Act - do whatever the GameOverScreen wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { PlayerInput(); } private void PlayerInput (){ if (Greenfoot.isKeyDown("enter")== true){ Greenfoot.setWorld(new LinkWorld()); } } } "
davmac davmac

2016/2/19

#
Please:
  • Don't revive years-old discussions. Create a new discussion and link to the old one if you need to.
  • Read the guidelines for posting code, in particular, you should correct your indentation and use 'code' tags
  • Be more specific. "won't work" doesn't explain what the issue is.
Do not post a follow-up here. Create a new discussion.
You need to login to post a reply.