Hello, I'm programming a game where the counter starts with 32. Everytime an enemy enters the field, it withdraws 1 (it says: "Enemies left: .."). If the counter is 0, I want the game to move forward to Level 2 but I don't know how to write it.
I have the code
and the 'private int level' & 'level = 1' (<-- in the act method)
in my Level1 class and
I have this
in my Counter class.
but it doesn't work
public void nextLevel()
{
if (counter.getScore() == 0) {
if (level == 1) {
level = 2;
Greenfoot.setWorld(new Level2());
}
else {
level = 1;
Greenfoot.setWorld(new Level1());
}
}
}
/**
* Return the current counter value.
*/
public int getScore()
{
return score;
}
