Question

Using box2d (+cocos2d iPhone) , i have to create a simple rect , that will be hollow- that means having a square , that i can put bodies into it (like a cage ) . I need to create that body with 4 B2VEC vectors . How do i code that ?

The box2D says that :

Polygons are solid and never hollow
  1. how can i create a hollow square
  2. how do you code that with 4 b2vec2

Thanks .

Was it helpful?

Solution

ok , you can do it with a chain shape for example(docs) :

b2Vec2 vs[4];

vs[0].Set(1.7f, 0.0f);

vs[1].Set(1.0f, 0.25f);

vs[2].Set(0.0f, 0.0f);

vs[3].(-1.7f, 0.4f);



b2ChainShape chain;

chain.CreateChain(vs, 4);

//than construct a body with this fixture

OTHER TIPS

A chain shape is the way to go. Take a look at this post which explains how to create a roulette wheel. It is similar in that you want to have objects "inside" other objects.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top