我正在使用Android Studio和LibGDX创建一个崩溃测试游戏,我拥有游戏装置所需的一切,但是我想在Box2D中创建一个颠倒的三角形,显然,它是'不会看起来像这样,但这张图片是给你一个例子
我尝试更改Box2D中的代码顺序,但它没有创建倒三角形,如下所示:
private Fixture createcollisionFixture(Body collisionBody) {
Vector2[] vertices = new Vector2[3];
vertices[0] = new Vector2(-0.5f, -0.5f);
vertices[1] = new Vector2(0.5f, -0.5f);
vertices[2] = new Vector2(0, 0.5f);
PolygonShape shape = new PolygonShape();
shape.set(vertices);
Fixture fix = collisionBodyBody.createFixture(shape, 1);
shape.dispose();
return fix;
}
我将其更改为:
private Fixture createcollision2Fixture(Body collision2Body) {
Vector2[] vertices = new Vector2[3];
vertices[2] = new Vector2(0, 0.5f);
vertices[1] = new Vector2(0.5f, -0.5f);
vertices[0] = new Vector2(-0.5f, -0.5f);
PolygonShape shape = new PolygonShape();
shape.set(vertices);
Fixture fix = collision2Body.createFixture(shape, 1);
shape.dispose();
return fix;
}
但它继续作为第二张图片加载,而不是倒三角形,我该如何解决这个问题?非常感谢帮助。