I'm a noob here. I get the following message when the projectile reaches the end of the world. I've tried many things to correct this but none work. I don't get the error when I shoot up or down but I do get it when I shoot left or right. What am I doing wrong?
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.
public class Shot extends Actor
{
private int direction, speed;
public Shot(int dir)
{
direction = dir;
speed = 15;
}
public void act()
{
setRotation(direction);
move(speed);
setLocation(getX() - 1, getY());
if (getOneIntersectingObject(Seal.class) != null)
{
getWorld().removeObject(this);
return;
}
if (isAtEdge())
{
getWorld().removeObject(this);
return;
}
}
}
