Android GDX Box2D三角形

时间:2012-02-25 22:09:36

标签: android box2d libgdx

我需要Box2D GDX And​​roid的三角形形状定义。 我只是将宽度除以3还是有一个类? 这是普通矩形的代码:

            _rect1 = CCSprite.sprite("RectWood.png");
            _rect1.setPosition(CGPoint.make(-10, -10));
            this.addChild(_rect1);
            //Create box
            BodyDef Box1BodyDef = new BodyDef();
            Box1BodyDef.type = BodyType.DynamicBody;
            Box1BodyDef.position.set(350/PTM_RATIO, 80/PTM_RATIO);

            // The body is also added to the world.
            Body Box1Body = _world.createBody(Box1BodyDef);
            Box1Body.setUserData(_rect1);

            // Define the shape.
            PolygonShape Box1Box = new PolygonShape();


            Box1Box.setAsBox(10/PTM_RATIO, 50/PTM_RATIO);
            Box1Body.createFixture(Box1Box,1.5f);

:)谢谢,乔

1 个答案:

答案 0 :(得分:3)

只需向Box1Box对象添加3个顶点,而不是调用setAsBox()