[英]car moving body in box2d with cocos2d-x
我有車身和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中如何制作? 任何例子..
Collison檢測所有打算使用box2d的東西。
cocos2D-x Doc包含有關Box2D的文章。http://www.cocos2d-x.org/docs/manual/framework/native/physics/physics-physics-integration/不夠詳細,但足以作為起點。
此外,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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.