gpt4 book ai didi

Android GDX Box2D 三角形

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:58:29 41 4
gpt4 key购买 nike

我需要 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);

:) 谢谢,乔

最佳答案

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

关于Android GDX Box2D 三角形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9448528/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com