Hello! I am new to greenfoot, and this error always pops up for me.
Here is the error code for this case
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed.
at greenfoot.Actor.failIfNotInWorld(Actor.java:663)
at greenfoot.Actor.isTouching(Actor.java:925)
at Player.onFloor(Player.java:22)
at CaveMkr.act(CaveMkr.java:103)
at greenfoot.core.Simulation.actActor(Simulation.java:568)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:526)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205)
Here is the Player code
And here is the CaveMkr code throwing an error
Thanks for helping!
public class Player extends Actor
{
boolean onfloor = true;
/**
* Act - do whatever the Player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
getWorld().setPaintOrder(Player.class, Tile.class,CaveMkr.class);
}
public boolean onFloor()
{
return isTouching(Tile.class);
}
}if(Greenfoot.isKeyDown("left")){
wall.setLocation(wall.getX()+1, wall.getY());
if(player.onFloor() == false){
wall.setLocation(wall.getX()-1, wall.getY());
}
}

