This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Anthony_Tatowicz presents ...


Simple Space Game

so when ever the astroid hits the edge of the wall it throws an exception.. i know why but im not sure how to fix it. please help thanks

5294 views / 1 in the last 7 days

Tags: with-source

open in greenfoot
Your browser does not support the canvas tag.


What is the stack trace for the exception?
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. at greenfoot.Actor.failIfNotInWorld( at greenfoot.Actor.getOneIntersectingObject( at Objects.onContact( at Astroid.removeAstroid( at Astroid.act( at greenfoot.core.Simulation.actActor( at greenfoot.core.Simulation.runOneLoop( at greenfoot.core.Simulation.runContent( at


Looks like you're removing the actor, and then checking for collision (which requires that the actor is still in the world). Change the order around so you check for collision first. Alternatively, search for the exception in the discussion forum - this is a common problem.

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.