Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.