Hi,
I have a timer running from 0 to 300. if it reaches 300 I get a image up that says well done. I want to be able to have an image appear telling me the amount of time that the user has lasted if they do not get to 300.
Timer Code:
Timer wrote...
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
public class Timer extends Actor
{
public int time = 0;
public int count = 65;
public void act()
{
// Add your action code here.
if(time == 200)
{
display2();
Greenfoot.stop();
return;
}
if(counter())
{
time ++;
count = 65;
}
display();
}
public boolean counter()
{
if(count > 0)
{
count--;
}
return count == 0;
}
private void display()
{
setImage(new GreenfootImage("Game Ends : " + time, 30, Color.WHITE, Color.BLACK));
}
public void display2()
{
getWorld().removeObjects(getWorld().getObjects(LadyBug.class));
getWorld().removeObjects(getWorld().getObjects(Spider.class));
setImage(new GreenfootImage("Well Done you have completed the Game! \n you lasted 200 Seconds", 50, Color.WHITE, Color.BLACK));
}
public void display3()
{
setImage(new GreenfootImage("Well Done you have completed the Game! \n you lasted\n" + "want ths time shown here"), 50, Color.WHITE, Color.BLACK));
}
public void setTime()
{
time = 0;
}
public boolean isTimeUp()
{
return time == 200;
}
i want to have the display 3 store the current time to be shown in a different class.
