문제

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?

도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top