私はそのようなコードで多角形の物理体を作成しようとしています:
final float halfWidth = pAreaShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
final float halfHeight = pAreaShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
final float centerX = 0;
final float left = -halfWidth;
final float right = halfWidth;
final float top = -halfHeight + 9f / PIXEL_TO_METER_RATIO_DEFAULT;
final float bottom = halfHeight;
final PolygonShape shape1 = new PolygonShape();
final Vector2[] vertices = {
new Vector2(centerX, bottom),
new Vector2(left+8f/PIXEL_TO_METER_RATIO_DEFAULT, bottom-19f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(left+7f/PIXEL_TO_METER_RATIO_DEFAULT, bottom-23f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(left+10f/PIXEL_TO_METER_RATIO_DEFAULT, top+14f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(left+13f/PIXEL_TO_METER_RATIO_DEFAULT, top+8f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(right-14f/PIXEL_TO_METER_RATIO_DEFAULT, top+8f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(right-11f/PIXEL_TO_METER_RATIO_DEFAULT, top+14f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(right-9f/PIXEL_TO_METER_RATIO_DEFAULT, bottom-23f/PIXEL_TO_METER_RATIO_DEFAULT),
new Vector2(right-10f/PIXEL_TO_METER_RATIO_DEFAULT, bottom-19f/PIXEL_TO_METER_RATIO_DEFAULT)
};
Body body = PhysicsFactory.createPolygonBody(pPhysicsWorld, pAreaShape, vertices, pBodyType, pFixtureDef);
可変頂点には、この形状の頂点が含まれています。
そして、それは機能しません—アプリケーションは起動し(黒い画面とアプリケーションのタイトルバーを表示します)、エラーなしで終了します(LogCatにはクラッシュダイアログとエラーはありません)。
しかし、頂点配列の要素の1つを削除すると、正常に機能します。
私は何を間違っているのですか?