Iv been reading other discussions on this topic but I dont really understand it. How do I make a clock count up? I canth of any way on how to do it.
// *** in World class ***
// add instance fields
private Actor clock = new Actor(){};
private int clockTime;
private int clockRegulator;
// in constructor
clock.setImage(new GreenfootImage("Time: "+clockTime, 20, java.awt.Color.black, null);
addObject(clock, 100, 20);
// in act method
runClock();
// new method
private void runClock()
{
clockRegulator = (clockRegulator+1)%50;
if (clockRegulator == 0)
{
clockTime++;
clock.setImage(new GreenfootImage("Time: "+clockTime, 20, java.awt.Color.black, null);
}
}clockRegulator++; if (clockRegulator == 50) clockRegulator = 0;
int clock = 0;
clock++;
//Under the act Method
if(clock == 300){ //This is the number of frames you can change Remember, 50-60 frames, is about 1 second.
doThisMethod(); //Complete the method under your choosing
clock = 0; //resets the clock again
}clock.setImage(new GreenfootImage("Time: "+clockTime, 20, java.awt.Color.black, null));