车载移动体在box2d与cocos2d-x

时间:2014-03-12 10:37:11

标签: ios iphone box2d cocos2d-x physics

我有车身和2层作为单独的图像。

如何修复车身(带有cocos2d-x的box2d)和移动动画。(我需要旋转等级)和跳跃等等?,

在正常的cocos2d-x中,我可以制作这样的东西..

car = CCSprite::spriteWithFile("car.png");
car->setPosition(ccp(car->getContentSize().width/2+30, car->getContentSize().height-19));
this->addChild(car, 10);

tire = CCSprite::spriteWithFile("tire.png");
tire->setPosition(ccp(tire->getContentSize().width/2+43, tire->getContentSize().height+8));
this->addChild(tire, 10);

tire1 = CCSprite::spriteWithFile("tire.png");
tire1->setPosition(ccp(tire->getContentSize().width/2+136, tire->getContentSize().height+8));
this->addChild(tire1, 10);

CCRotateBy *Rot = CCRotateBy::actionWithDuration (1.0f, 360);
CCRepeatForever *rep = CCRepeatForever::actionWithAction(Rot);
CCRotateBy *Rot1 = CCRotateBy::actionWithDuration(1.0f, 360);
CCRepeatForever *rep1 = CCRepeatForever::actionWithAction(Rot1);
tire->runAction(rep);
tire1->runAction(rep1);

但是在box2d怎么做?任何一个例子..

用于所有计划使用box2d的collison detction。

1 个答案:

答案 0 :(得分:1)

cocos2D-x Doc包含一篇关于Box2D的文章.. http://www.cocos2d-x.org/docs/manual/framework/native/physics/physics-integration/en 不是那么详细,但足以开始。

此外,cocos2D-x框架测试包含Box2D和Chipmumk物理示例的示例。 http://www.cocos2d-x.org/docs/manual/framework/native/getting-started/v3.0/how-to-run-cpp-tests-on-win32/en