Question

I need to read data of a Body, but I don't have World object yet. This Body is needed only to store informations about it. Do I have to have a dedicated World object for that?

Était-ce utile?

La solution

I believe the answer is Yes, you need to a Box2D World to add Box2D bodies to..

Without a World, the body has nothing to be a part of. You can have multiple Worlds and each of them has their own bodies associated with it, which are completely separate.

It sounds like you may be trying to solve a different problem...maybe the "Entity" vs. "The body that the Entity is representing." That is to say, a game entity (ball, car, "thing", etc.) is represented by a class that creates a body when it needs to be represented in the physics world.

When the body is created, set its userdata to reference the entity that owns it.

Is this where you are going?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top