【发布时间】:2014-03-12 10:37:11
【问题描述】:
我有车身和 2 层作为单独的图像。
如何修复为车身(box2d with cocos2d-x)和移动动画。(我需要旋转层)和跳跃等,?
在普通的 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 的碰撞检测。
【问题讨论】:
-
您必须使用 auto scene = Scene::createWithPhysics() 创建场景才能在场景中启用物理;
-
@sunny1304 你能举一些例子来学习上面的box2d动画和碰撞检测
标签: ios iphone box2d cocos2d-x physics