cocos2dバージョンv1.0.1では
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;
}