Hello,
I have an object Arrow that has to eat Enemy1, Enemy2, Enemy3 and Enemy4.
It can be shot from a person as many times as you can, but if it has eaten one of those enemies, it has to remove itself. My Arrow class is a subclass of Weapons.
Now I get this error called: java.lang.IllegalStateException: Actor not in world.
In my 'tryToEat' method, I have:
+ this for Enemy2, 3 & 4
And in my Weapons class I have:
Anyone know how to solve this?
1 2 3 4 5 | if (canSee(Enemy1. class )) { eat(Enemy1. class ); getWorld().removeObjects(getWorld().getObjects(Arrow. class )); } |
1 2 3 4 5 | public boolean canSee(Class clss) { Actor actor = getOneObjectAtOffset( 0 , 0 , clss); return actor != null ; } |
1 2 3 4 5 6 7 | public void eat(Class clss) { Actor actor = getOneObjectAtOffset( 0 , 0 , clss); if (actor != null ) { getWorld().removeObject(actor); } } |