1
我想让box2d加速度计工作,我有一个汽车精灵,并希望它左右移动,当iPhone倾斜。box2d加速度计如何使其工作
这里是精灵的代码:
- (void)spawnCar {
car = [CCSprite spriteWithSpriteFrameName:@"car.jpg"];
car.position = ccp(160, 250);
car.tag = 2;
[self addBoxBodyForSprite:car];
[_spriteSheet addChild:car];
}
如何实现加速度计为左,右工作吗?
但如何使实际精灵的举动? – sahil 2012-02-21 13:40:01
@sahil你必须得到身体位置,然后更新精灵来匹配那个位置。请参阅http://www.raywenderlich.com/28602/intro-to-box2d-with-cocos2d-2-x-tutorial-bouncing-balls上的“tick”方法 – McArthey 2013-04-14 16:55:01