Hi
Is it possible to create a timer that will stop the game after 60 seconds or a specified time limit.
If it is possible then how can i achieve this?


private timer = 0;
if (timer>0) { timer--; if(timer == 0) Greenfoot.stop(); }
private timer = 0;
int timer = 0;
import greenfoot.*; import java.awt.Color; public class Text extends Actor { public Text() { this(""); } public Text(String text) { setText(text); } public void setText(String text) { setImage(new GreenfootImage(text, 24, Color.black, new Color(0, 0, 0, 0))); } }
// add world instance field Text timerText = new Text(); // in the constructor (or a method it calls) addObject(timerText, 100, 15); //wherever timerText.setText("Time left: " + (timer/60)); // insert after 'timer--;' in the 'act' method (or a method it calls) if (timer%60==0) timerText.setText("Time left: " + (timer/60));
Text timerText = new Text();
public class ???????? extends World { Text timerText=new Text(); // other fields public ????????() { super(...// etc.