This is the code that I have for my time and the text...
The time works well and the text appears right but the problem is that the text appears "Time left: 15 seconds" even after clicking run... In short the number written in the text doesn't decrease as the time goes... What should I add more to make sure that the number is decreasing as the time flows...
private int timer = 900;
public MyWorld()
{ Text timerText = new Text();
addObject(timerText, 115, 15);
timerText.setText("Time left: " + (timer/60) + " " + "seconds");}
public void act(){
if (timer>0)
{
timer--;
Random r = new Random();
if (timer%60==0) {
timerText.setText("Time left: " + (timer/60) + " " + "seconds");
}
if(timer == 0)
{
Gameover gameover = new Gameover();
addObject(gameover, 305, 200);
Greenfoot.stop();
}
}
}
