简体   繁体   中英

car moving body in box2d with cocos2d-x

i have car body and 2 tiers as seprate images .

how to fix as car body(box2d with cocos2d-x) and moving animation.(i need to rotate tier) and jumping etc.,?

in normal cocos2d-x i can make something like this..

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);

but in box2d how to make? any example..

for collison detction for all thing planing to use box2d.

cocos2D-x Doc contains an article about Box2D.. http://www.cocos2d-x.org/docs/manual/framework/native/physics/physics-integration/en not that detailed, but good enough to start with.

Also cocos2D-x framework test contains example of both Box2D and Chipmumk physics example. http://www.cocos2d-x.org/docs/manual/framework/native/getting-started/v3.0/how-to-run-cpp-tests-on-win32/en

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM