Can anyone help me make a simple timer, that can count down from 1 minute?
and after 1 mute, the world should reset.
Thanks in advance.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | private int time = 0 ; public WorldName() { super ( /**...*/ ); Greenfoot.setSpeed( 50 ); prepare(); } private void prepare() { time = 3300 ; //adding objects here } public void act() { time--; if (time == 0 ) { removeObjects(getObjects( null )); prepare(); /** OR **/ Greenfoot.setWorld( new WorldName()); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | private int time = 0 ; public WorldName() { super ( /**...*/ ); Greenfoot.setSpeed( 50 ); prepare(); } private void prepare() { time = 3300 ; //adding objects here } public void act() { time--; if (time == 0 ) { removeObjects(getObjects( null )); prepare(); /** OR **/ Greenfoot.setWorld( new WorldName()); } } |