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

2012/5/2

coding error...need help!

tomcoleman1994 tomcoleman1994

2012/5/2

#
when i fire a rocket and hits the out side of my world. it comes up with an error saying:- 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:655) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:859) at Mover.canSee(Mover.java:83) at Rocket.blowUpVehicle(Rocket.java:29) at Rocket.act(Rocket.java:21) 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)
nccb nccb

2012/5/2

#
My guess is that either Rocket.act or Rocket.blowUpVehicle are removing the rocket from the world, and then after that, you look to see if it hit anything nearby. Because the rocket is no longer in the world, looking for nearby objects fails (as the error says: "Either has not yet been inserted, or it has been removed." Switch the order: check for hitting things before you remove the rocket from the world.
You need to login to post a reply.