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

Report as inappropriate.

Anthony_Tatowicz
Anthony_Tatowicz presents ...

2012/3/4

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

6220 views / 9 in the last 7 days

Tags: with-source

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

2012/3/5

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(Actor.java:656) at greenfoot.Actor.getOneIntersectingObject(Actor.java:905) at Objects.onContact(Objects.java:33) at Astroid.removeAstroid(Astroid.java:56) at Astroid.act(Astroid.java:19) at greenfoot.core.Simulation.actActor(Simulation.java:507) at greenfoot.core.Simulation.runOneLoop(Simulation.java:470) at greenfoot.core.Simulation.runContent(Simulation.java:204) at greenfoot.core.Simulation.run(Simulation.java:194)
davmacdavmac

2012/3/5

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.