How do I move to the next level after I have reached a certain score. Level one requires the player to get a score of 20 in order to move on to level two of my game. This is what i have got at the moment and it's not working.
This is the code for my counter
public class Counter extends Actor
{
private int totalCount = 0;
int Counter = 0;
public Counter ()
{
setImage(new GreenfootImage("0" , 20, Color.WHITE, Color.BLUE));
}
public void bumpCount (int amount)
{
totalCount += amount;
setImage(new GreenfootImage("" + totalCount, 20, Color.WHITE, Color.BLUE));
}
private void nextLevel()
{
if (Counter >= 20)
{
if (getWorld() instanceof level1) Greenfoot.setWorld(new level2());
else if (getWorld() instanceof level2) Greenfoot.setWorld(new level3());
else if (getWorld() instanceof level3) Greenfoot.setWorld(new Win());
}
}
}

