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;
}