2012-02-13 7 views
4

私はAndEngineをゲーム開発に使用しています。私の問題は、ポリゴンのボディをスプライトに設定する方法を正確には分かりません。エンジンのポリゴン

ここで言及したコードはhttp://www.andengine.org/forums/gles1/complex-collision-surface-t5593.html#p24822でしたが、成功しませんでした。

これを動作させる方法は他にありますか?また、私は私のコードを添付:

if (type.equals(ObjectType.STAIRS)) { 
      final BodyDef bodyDef = new BodyDef(); 
      bodyDef.type = type.bodyType; 
      bodyDef.position.x=5; 
      bodyDef.position.y=5; 
      final Body mBody = body; 


      PolygonShape pol1 = new PolygonShape(); 
      Vector2[] vertices = {//rectangular 
        new Vector2(0, 
          -sprite.getHeight() * 0.5f),//top right 
        new Vector2(-sprite.getWidth() * 0.5f,//top left 
          -sprite.getHeight() * 0.5f), 
        new Vector2(-sprite.getWidth() * 0.5f,//bottom left 
          sprite.getHeight() * 0.5f), 
        new Vector2(0,//bottom right 
          sprite.getHeight() * 0.5f) }; 
      pol1.set(vertices); 
      fixtureDef.shape = pol1; 
      mBody.createFixture(fixtureDef);    
      pol1.dispose(); 


      final PolygonShape pol2 = new PolygonShape(); 
      Vector2[] vertices2 = {//triangular 
        new Vector2(0, 
          -sprite.getHeight() * 0.5f),//top 
        new Vector2(0, 
          sprite.getHeight() * 0.5f),//left 
        new Vector2(sprite.getWidth() * 0.5f, 
          sprite.getHeight() * 0.5f),//right 
        }; 
      pol1.set(vertices2); 
      fixtureDef.shape = pol2; 
      mBody.createFixture(fixtureDef); 
      pol2.dispose(); 
      body=mBody; 

答えて

1

私は最終的にPhysicsEditorとit'sローダーを使用してこの問題を解決:あなたはそれを作るためにメーターの比を一定にGETスケール幅とピクセルを使用していなかったようhttp://www.codeandweb.com/physicseditor

0

に見えますメーターに入る。

ボディをスプライトに登録する必要があります。