Andengine - 创建一个简单的多边形体

时间:2014-01-29 17:20:33

标签: c# java andengine

我正在尝试学习AndEngine,我在Visual STudio中制作了一个可以制作多边形顶点的程序。 但我无法弄清楚如何将它添加到物理世界..

Sprite cartman = new Sprite(50, 50, ballTextureRegion,
            this.getVertexBufferObjectManager());
    cartman.setRotation(50);
    final FixtureDef PLAYER_FIX = PhysicsFactory.createFixtureDef(10.0f,

    .5f, 0.3f);

    float[] vertices = new float[] { 16, 20, 16, 20, 39, 4, 69, 8, 83, 22,
            85, 44, 97, 56, 98, 68, 95, 69, 91, 78, 88, 82, 88, 91, 12, 91,
            8, 76, 4, 69, 0, 60, 14, 44, 13, 30 };
    for (int i = 0; i < vertices.length; i++)
        vertices[i] /= PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
    PolygonShape ps = new PolygonShape();
    ps.set(vertices);


     .....

    this.scene.attachChild(cartman);

    physicsWorld.registerPhysicsConnector(new PhysicsConnector(cartman,
            body, true, false));

我无法理解什么是iShape .. 有人能帮助我吗?

0 个答案:

没有答案