Hello,
I’m building a game where an object is supposed to blow up when it collides with another object. To animate the explosion, I have created small “splinter” images that are supposed to fly in all directions to simulate the exploded object. The splinter can of course not be visible until the collision and I therefore wanted to create them in the collision listener. The problem is that when I try to add physics to the splinter images I get an error message saying
ERROR: physics.addBody() cannot be called when the world is locked and in the middle of number crunching, such as during a collision event.
I then tried to create the images and add physics to them and “hide” them outside the screen. Apart from being a very clumsy solution, it still did not work since I got an error message when I tried to move all the splinters to the center of the explosion before applying force to make them fly around.
In other words: does anyone know how to animate an explosion with flying splinter (by added force and affected by gravity) at the time of a collision?
Thanks for your help!