【问题标题】:car moving body in box2d with cocos2d-x使用 cocos2d-x 在 box2d 中移动车身
【发布时间】: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


【解决方案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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多