I am trying to make an actor remove itself when touched by another actor but get the java.lang.IllegalStateException: Actor not in world. error.
This is the code for getting the actor to remove itself:
public void getEatenbyFly(){
Actor burger;
burger = getOneObjectAtOffset(0,0, Fly.class);
if (burger != null){
getWorld().removeObject(this);
return;}
}
public void getEatenbyAnt(){
Actor burger;
burger = getOneObjectAtOffset(0,0, Ant.class);
if (burger != null){
getWorld().removeObject(this);
return;}
}
Thanks in advance!