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

2012/1/12

Switching image then removing.

Mikeson Mikeson

2012/1/12

#
Hi got scenario going where in it and object colides with another object then and explosen image occurs. What I have so far works except the the explosin does not remove. I used the code from the scenario where the crab eats the worms. public void hit() { Actor emeny; Actor explode; explode = getOneObjectAtOffset(0,0, explode.class); emeny = getOneObjectAtOffset(0,0, Emeny.class); if (emeny !=null) { World world; world = getWorld(); getWorld().addObject( new explode(),getX(),getY()); world.removeObject(emeny); world.removeObject(this); world.removeObject(explode); } Also is their away to remove a fration of an object at point of contact ?
danpost danpost

2012/1/12

#
The reason the explode object does not remove is because you are removing 'this' from the world first. Now there is no 'world' referenced. Switch the last two lines of code and the explode should remove. As far as fraction of objects, the only ways I can think of are (1) if you build the object in parts, or (2) if you change the image to reflect the remo val at given points.
You need to login to post a reply.