I'm creating a game where aliens lose if their population becomes 0. I use a static variable to do this. The game starts off with 2 aliens, and the static variable is set to 0. Therefore, when the static variable = -2, there should be no aliens, and I want the game to stop at this point and reset the static variable to 0. However, the game neither stops nor sets the static variable to zero. I have provided the code below for stopping the game:
public void checkGameOver2() {
if (alienCounter == -2) { //the static variable is the alien counter
Greenfoot.stop();
getWorld().showText("Aliens lose!", 400, 400);
alienCounter = 0;
}
}
Is there something wrong with my code or is there a bug?

