我正在做一场比赛。在那个动人的男孩精灵中创建了身体。男孩的身体在移动正面或背面时会掉下来。
如何固定身体y轴0?
CCSprite *boySprite=[CCSprite spriteWithFile:@"object_boy.png"];
boySprite.position=ccp(100,50);
b2BodyDef boyBodyDef;
boyBodyDef.type = b2_dynamicBody;
boyBodyDef.linearDamping = 1;
boyBodyDef.angularDamping = 1;
boyBodyDef.position.Set(25.0f/PTM_RATIO,(150)/PTM_RATIO);
boyBodyDef.angle=0;
boyBodyDef.userData = _boy;
boyBody = world->CreateBody(&boyBodyDef);
b2PolygonShape boyBox;
b2FixtureDef boyBoxDef;
boyBoxDef.shape = &boyBox;
boyBoxDef.density = 0.5F;
boyBox.SetAsBox(11.0f/PTM_RATIO, 30.0f/PTM_RATIO);
boyFixture = boyBody->CreateFixture(&boyBoxDef);
[self addChild:boySprite z:1];