2012-01-19 4 views
3

はcocos2dバージョンv1.0.1デベロッパーcocos2d setasedge問題

 groundBox.SetAsEdge(left,right); 

ではそれはそれは、以前のバージョン で削除されたように理にかなっている方法が存在しないというエラーとしてSetAsEdgeを使用しないする必要がありますしかし、私はボックスを作成しないでこれを行う方法がわかりません。代わりに、複数の線を頂点の配列を使用して作成しています(私の理解から)

- (void)createGroundEdgesWithVerts:(b2Vec2 *)verts numVerts:(int)num 
        spriteFrameName:(NSString *)spriteFrameName { 
    CCSprite *ground = 
    [CCSprite spriteWithSpriteFrameName:spriteFrameName]; 
    ground.position = ccp(groundMaxX+ground.contentSize.width/2, 
          ground.contentSize.height/2); 
    [groundSpriteBatchNode addChild:ground]; 

    b2PolygonShape groundShape; 

    b2FixtureDef groundFixtureDef; 
    groundFixtureDef.shape = &groundShape; 
    groundFixtureDef.density = 0.0; 

    // Define the ground box shape. 
    b2PolygonShape groundBox;  

    for(int i = 0; i < num - 1; ++i) { 
     b2Vec2 offset = b2Vec2(groundMaxX/PTM_RATIO + 
           ground.contentSize.width/2/PTM_RATIO, 
           ground.contentSize.height/2/PTM_RATIO); 
     b2Vec2 left = verts[i] + offset; 
     b2Vec2 right = verts[i+1] + offset; 

     groundShape.SetAsEdge(left,right); 

     groundBody->CreateFixture(&groundFixtureDef);  
    } 

    groundMaxX += ground.contentSize.width; 
} 
+0

あなたはBOX2Dの代わりに、cocos2d –

+0

について話しているあなたはそのための色を設定しない方法もええ技術的にその両方 – Luke

答えて

2

これはbox2dです。新しいバージョンでは、b2EdgeShapeというクラスがあり、Set()というメソッドがあると思います。ポリゴンシェイプと廃止されたsetEdgeメソッドの代わりにこのメソッドを使用できます。

http://www.box2d.org/manual.html

参照セクション4.5

2

新しいCocos2D + BOX2Dサンプルプロジェクトは、それをしないかチェックすることができます。ここで

は、私がKobold2Dに画面サイズのボックスを作成方法は次のとおりです。

// for the screenBorder body we'll need these values 
    CGSize screenSize = [CCDirector sharedDirector].winSize; 
    float widthInMeters = screenSize.width/PTM_RATIO; 
    float heightInMeters = screenSize.height/PTM_RATIO; 
    b2Vec2 lowerLeftCorner = b2Vec2(0, 0); 
    b2Vec2 lowerRightCorner = b2Vec2(widthInMeters, 0); 
    b2Vec2 upperLeftCorner = b2Vec2(0, heightInMeters); 
    b2Vec2 upperRightCorner = b2Vec2(widthInMeters, heightInMeters); 

    // Define the static container body, which will provide the collisions at screen borders. 
    b2BodyDef screenBorderDef; 
    screenBorderDef.position.Set(0, 0); 
    b2Body* screenBorderBody = world->CreateBody(&screenBorderDef); 
    b2EdgeShape screenBorderShape; 

    // Create fixtures for the four borders (the border shape is re-used) 
    screenBorderShape.Set(lowerLeftCorner, lowerRightCorner); 
    screenBorderBody->CreateFixture(&screenBorderShape, 0); 
    screenBorderShape.Set(lowerRightCorner, upperRightCorner); 
    screenBorderBody->CreateFixture(&screenBorderShape, 0); 
    screenBorderShape.Set(upperRightCorner, upperLeftCorner); 
    screenBorderBody->CreateFixture(&screenBorderShape, 0); 
    screenBorderShape.Set(upperLeftCorner, lowerLeftCorner); 
    screenBorderBody->CreateFixture(&screenBorderShape, 0); 
+0

は?好ましくは透明にする – ExceptionSlayer

関連する問題