I made a turret that shoots bullets for my game, but the bullets won't go away at the wall. Greenfoot gives an error. It says: Actor not in world. I don't know how to fix this. Can someone help? This is my code.
public void removeAtEdge()
{
if (getX()>595)
{
World world = getWorld();
getWorld().removeObject(this);
}
}
public void setLocation(int x, int y)
{
int oldX = getX();
int oldY = getY();
super.setLocation(x, y);
if(!getIntersectingObjects(Wall.class).isEmpty())
{
World world = getWorld();
getWorld().removeObject(this);
}
}
