0
\$\begingroup\$

I want to create a custom body which have very random shape like a table. So how to add/combine multiple fixtures into a body?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You have to use physics editor and using that you have to generate xml file which contains the fixture and body information. Using parsing you have to create PolygonShape, create a new fixture and assign it to the body.

for (int l = 0; l < size; l++)
    vector2s[l] = vectorList.get(l);

PolygonShape polygonShape = new PolygonShape();
polygonShape.set(vector2s);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef = PhysicsFactory.createFixtureDef(1, 0, 0.8f,
               false, Constants.CATEGORYBIT_BOMB,
                Constants.MASKBIT_BOMB, (short) 0);
fixtureDef.shape = polygonShape;
bombBody.createFixture(fixtureDef);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .