Hi,
I'm getting the following error:
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:656)
at greenfoot.Actor.getOneObjectAtOffset(Actor.java:860)
at Player.checkTeleport(Player.java:198)
at Player.act(Player.java:73)
at greenfoot.core.Simulation.actActor(Simulation.java:507)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:470)
at greenfoot.core.Simulation.runContent(Simulation.java:204)
at greenfoot.core.Simulation.run(Simulation.java:194)
The code looks like this.
This is in the act method:
if(checkTeleport()) {
Greenfoot.playSound("teleport.wav");
setLocation(400, 292);
}
This is not:
public boolean checkTeleport() {
Actor teleporter = getOneObjectAtOffset(0, 0, teleporter.class);
if(teleporter != null) {
return true;
} else {
return false;
}
}
Anyone got any ideas?
Apart from the error message everything works as it should.