答案 0 :(得分:0)
两个ChainShapes互不碰撞,使其中一个成为PolygonShape。 这对我有用:
BodyDef triangleDef = new BodyDef();
triangleDef.type = BodyDef.BodyType.DynamicBody;
triangleDef.position.set( 0, 0 );
Body triangleBody = this.world.createBody( triangleDef );
PolygonShape triangleShape = new PolygonShape();
triangleShape.set( new float[]{ 0, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f } );
triangleBody.createFixture( triangleShape, 1 );
triangleShape.dispose();
BodyDef groundDef = new BodyDef();
triangleDef.position.set( 0, 0 );
Body groundBody = this.world.createBody( groundDef );
ChainShape groundShape = new ChainShape();
groundShape.createLoop( new float[]{ -10, 10, -10, -10, 10, -10, 10, 10 } );
groundBody.createFixture( groundShape, 1 );
groundShape.dispose();