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.

Hey I have created my body using following code: (please read full description)

    Body polyBody;
    final BodyDef mBodyDef = new BodyDef();
    mBodyDef.type = BodyDef.BodyType.DynamicBody;
    mBodyDef.position.x = 20;
    mBodyDef.position.y = 5;
    polyBody= mPhysicsWorld.createBody(mBodyDef);       
    final PolygonShape mPoly = new PolygonShape();
    mPoly.set(vertices);
    objectFixtureDef.shape = mPoly;
    polyBody.createFixture(objectFixtureDef);
    mPoly.dispose();

Now it's time for connecting my polygon with body using PhysicsConnector and when I do mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(mPoly, polyBody, true, true)); it doesn't accept mPoly as I expect an IAreaShape instead.

Is there any way that i can parse my it to IAreaShape? or can anyone suggest how can I create a body without using sprite. Its strictly prohibited that I can't use sprite as I need to cut/slice my body further.

share|improve this question

1 Answer 1

I think you are working with AndEngine. You misunderstood the concept of PhysicsConnector. PhysicsConnector need sprite and body to create. But here mPoly is a PolygonShape object that has functionality of box2d not of sprite.

If you don't want to use sprite then there is no need of PhysicsConnector. Basically PhysicsConnector used to attach sprite with body. So developer does not need to render it manually.

Also you have to use pixel to meter ratio to apply position and size of the object. In AndeEngine you can use constant with PhysicsConstant.PIXEL_TO_METER_RATIO.

share|improve this answer

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.