My countdown code, immediately switches to 2 and stays stuck, i do not know why.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Countdown here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Countdown extends Actor
{
private GreenfootImage Countdown3 = new GreenfootImage("Countdown3.png");
private GreenfootImage Countdown2 = new GreenfootImage("Countdown2.png");
private GreenfootImage Countdown1 = new GreenfootImage("Countdown1.png");
private GreenfootImage CountdownGo = new GreenfootImage("CountdownGo.png");
private static final int countdowntime = 50;
private int countdowntimer = Integer.MAX_VALUE;
/**
* Act - do whatever the Countdown wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
Countdown3();
}
public void Countdown3()
{
if(countdowntimer > countdowntime)
{
Countdown2();
}
else
{
countdowntimer++;
}
}
public void Countdown2()
{
setImage(Countdown2);
countdowntimer = 0;
if(countdowntimer > countdowntime)
{
Countdown1();
}
else
{
countdowntimer++;
}
}
public void Countdown1()
{
setImage(Countdown1);
countdowntimer = 0;
if(countdowntimer > countdowntime)
{
CountdownGo();
}
else
{
countdowntimer++;
}
}
public void CountdownGo()
{
setImage(CountdownGo);
countdowntimer = 0;
if(countdowntimer > countdowntime)
{
World world;
world=getWorld();
world.removeObject(this);
}
else
{
countdowntimer++;
}
}
}
