how do you creat a counter that counts down from 30 seconds when the game is started??
public void Counter()
{
startTime = System.currentTimeMillis();
}
public void act()
{
if (startTime != 0 && startTime <= System.currentTimeMillis() + 30000) //the 30000 part means 30 seconds
{
startTime = 0;
doSomething();
}
}
public void doSomething()
{
Greenfoot.stop();
}
public void act()
{
if (startTime != 0 && startTime <= System.currentTimeMillis() + 30000) //the 30000 part means 30 seconds
{
startTime = 0;
doSomething();
}
}
private boolean reached30secs = false;
public void act()
{
if (reached30secs = false && System.currentTimeMillis() - startTime >= 30000)
{
doSomething();
reached30secs = true;
}
}private long startTime;