Quantcast
Channel: cocos2d-x - Cocos Forums
Viewing all articles
Browse latest Browse all 2748

How to make the wheels rotate depending on the speed?

$
0
0

Hi everyone. I have a task to make a moving car, The car doesn’t move itself, its wheels rotate and the road moves. And so how can i synchronize the rotation and the moving? Any ideas? Class Action is avoid to use.
The wheels (w1 and w2) moving code in Update():
auto rot = w1->getRotation(); rot += 10 * delta * coefSpeed; w1->setRotation(rot); w2->setRotation(rot);
The road moving code in Update():
if ((road->getPositionX() - coefSpeed * 0.5) <= origin.x) road->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 4 + origin.y)); else road->setPositionX(road->getPositionX() - coefSpeed * 0.5);

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2748

Latest Images

Trending Articles



Latest Images