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

2012/5/7

Need help fine tuning my game

joey511 joey511

2012/5/7

#
Hey all I managed to get a little game going but it isn't quite working the way I want it to so I was wondering if you could help me out. You can find my scenario here! I want the rock to explode when a bullet makes contact with it then form debris but I keep getting some sort of error. And I was wondering if there is a way to have the rocks not added within 100 pixels of the rocket when initializing the game? Oh and what is a simple code for making the rocks move around?
davmac davmac

2012/5/7

#
I keep getting some sort of error.
A little vague... errors come with messages. Read the message! And post it if you still don't understand it.
joey511 joey511

2012/5/7

#
Sorry for the lack of details..I was kind of frustrated that i couldn't get it to work and wrote that question in a rush before going for a smoke break .. The error I'm getting is 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. I think it's a problem in the bullet.java code but I'm not quite sure how to fix it as I attempt to remove the Rock from the world if the bullet makes contact with it. I also want to make it shatter into debris after the Rock is removed. Any suggestions welcome :) I uploaded the project onto google docs here OR the whole project in a .rar file downloadable here
davmac davmac

2012/5/7

#
Well, on the first issue, you need to avoid doing anything which is dependent on the actor's location - such as calling getX()/getY() or collision checking methods - after you've removed the actor. You can usually do this by returning from the act() method as soon as you've removed the actor, using the 'return' statement: if (...) { getWorld().removeObject(this); return; }
You need to login to post a reply.