Hello,
first of all I'm sorry for my English, it's far from being perfect.
So, we've started programming with Java & Greenfoot a few weeks ago and I never used Java before.
Our task is do create some kind of RPG with different levels.
I want my hero (Robot) to switch levels as soon as a door in World 1 is removed which happens when Robot has a key in his inventory. This function is placed into the Robot class.
So I tried to implement a bool return statement as soon as this happens.
Switching levels has to be controlled by a subclass of World, "Weltenverwalter" (World-Administration).
But I always get an error message that there is no such variable.
These parts of my sourcecode are here;
From my robot class;
and the part from my World-Administration;
/**
* Checks if a door can be removed
*/
public boolean unlockDoor()
{
Actor object = getOneIntersectingObject(Door.class);
if (object != null && !inventory.isEmpty()
&& inventory.get() instanceof Key) { // Bonusaufgabe
inventory.clear();
getWorld().removeObject(object);
return true;
} else {
return false;
}
}public void checkWorld()
{
if(Robot.unlockDoor);
{
if(Greenfoot.getWorld == Background);
{
Greenfoot.setWorld(Welt2);
}
if(Greenfoot.getWorld == Welt2);
{
Greenfoot.setWorld(Background);
}
}
}

