Hello,
I am fairly new to Greenfoot, and I'm trying to set up a platformer where the player can walk through a door to get to the next World, or level. What I've done is I've made a World array containing all the levels in the game (currently 2), and then tried to switch between them by using this code:
What happens, though, is that it claims it can't find the method getLevel, which is a public method in all my (2) World calsses, Level1 and Level2. This despite the fact that I've used the getWorld() method to access the current World... I get the feeling htere's something obvious I'm missing here. Please help!
public void levelUp()
{
Actor door = getOneObjectAtOffset(0, 0, Door.class);
if (door != null)
{
World world = getWorld();
int currentLevel = world.getLevel();
if (currentLevel != LEVEL_COUNT)
{
Greenfoot.setWorld(levelArray[currentLevel + 1]);
}
else
{
victory();
}
}
}
