Hey Guys, there is a problem thats driving me crazy.
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.
This error keeps coming up. The game continues to work well if it hits the monster. But as soon as I miss, the game stops and I get this error. I kinda understand what the problem, but why does the game stop as soon as I miss the monster. The bullet doesnt remove at world edge. Please Help me ASAP
public void act() { move(15); remove(); lookForMonster(); } public void remove() { if (atWorldEdge()) { getWorld().removeObject(this); return; } } public void lookForMonster() { if ( canSee (Monster.class)) { eat (Monster.class); Greenfoot.playSound ("Fire.wav"); getWorld().removeObject(this); return; } if (getWorld().getObjects(Monster.class).isEmpty()) { Greenfoot.stop(); } } public Bullet() { setRotation(Greenfoot.getRandomNumber(160)-80); } }