I made some changes, I removed the 'YouWin' and 'GameOver' actors, now they are World subclasses and here's the code:
< Code Omitted >
Remove lines 21 through 34 of the YouWin class. The only thing you may want to add to the class is a line to stop the scenario (which is not essential since this is a separate world):
Disregard the codes in level one, I removed the added ones which was these: (which means level 1 is back to its original codes)
public void act()
{
getObjects();
}
public void getObjects()
{
if (getObjects(Hero.class).isEmpty())
{
showGameOver();
}
if (getObjects(Zombie.class).isEmpty())
{
if (level == 3)
{
showYouWin();
}
else
{
levelUp();
}
}
}
They do, but how will they appear if my Hero is dead or if the game is accomplished?
That is what the code given for your world class does. It tests to see if conditions are right to end the game (or change levels). The methods that are called from there (the 'showGameOver' and 'showYouWin' methods) will have the code to set the new 'YouWin' and 'GameOver' worlds active (which ends the game) -- after you add it, of course.