Hello everybody,
i have a timer in my world that will count down from 20 and when it gets to 0 greenfoot stops.
but when it stops i want to add an gameoverscreen.
Is there someone that could help me???
if (timer>0)
{
timer--;
if (timer==0) Greenfoot.stop();
}
addObject(timerText, 95, 25);
timerText.setcc_Text("Time left:" + (timer/60));
if (timer%60==0) timerText.setcc_Text("Time left:" + (timer/60));
public void act()
{
if (timer>0)
{
timer--;
if (timer==0) Greenfoot.stop();
}
addObject(timerText, 95, 25);
timerText.setcc_Text("Time left:" + (timer/60));
if (timer%60==0) timerText.setcc_Text("Time left:" + (timer/60));
}public class cc_GameOver extends Actor
{
/**
* Act - do whatever the cc_GameOver wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public cc_GameOver()
{
setImage(new GreenfootImage("Game Over",48, Color.WHITE, Color.BLACK));
}
}if (timer>0)
{
timer--;
if (timer%60==0) timerText.setcc_Text("Time left:" + (timer/60));
if (timer==0) Greenfoot.stop();
}if (timer>0)
{
timer--;
if (timer%60==0) timerText.setcc_Text("Time left:" + (timer/60));
if (timer==0)
{
addObject(new cc_GameOver(),getWidth()/2, getHeight()/2);
Greenfoot.stop();
}
}