Developing a game where balls are added from the top in timely fashion. Is there a way to create a body and put it in a queue to be added later?
This is also needed for pooling purposes. When a body is removed from the game it is put in a pool and when a similar body is needed It is taken from the pool.
You can't create a body outside of a
b2World, as it is clearly stated in the Box2D documentation:That means you can only create a body with the method
b2World::CreateBody(), which automatically adds the created body to the world.However, you could create a pool of
b2BodyDefinstead ofb2Body, as they are completely independent from bodies:And you can link the body with the corresponding body definition by using the
userDatapointer.