Hi the plan was that when the girl have watered all 15 flowers, the game should end and a GameEnded sign should appere, but its happening before, its like the counter counts more than one. here is my code hope someone can see whats wrong
public class Flower extends Animal
{
private GreenfootImage smallFlower;
private GreenfootImage bigFlower;
private int counter;
public Flower()
{
smallFlower = new GreenfootImage("lilleBlomst.png");
bigFlower = new GreenfootImage("storBlomst.png");
setImage(smallFlower);
counter = 0;
}
public void act()
{
grow();
}
public void grow()
{
if(canSee(Girl.class))
{
setImage(bigFlower);
counter++;
if(counter==15)
{
World world= getWorld();
GameEnded ended = new GameEnded();
world.addObject(ended, world.getWidth()/2,world.getHeight()/2);
Greenfoot.stop();
}
}
}
}
thanks