position AnchorPoint of a sprite in Cocos2d

328 Views Asked by At

I'm rotating a wheel in cocos2d-js.

position of my wheel sprite -

sprite.setPosition(cc.p(size.width/2, size.height/2));

Anchor of the sprite -

sprite.setAnchorPoint(cc.p(0.5, 0.5));

But when I rotate the wheel, the sprite comes off from the center, rotating and moving at the same time. As if, it's rotating relative to another point, not the center of the wheel. I'm thinking the issue is with the setAnchorPoint.

Any idea how to fix it? Thanks.

1

There are 1 best solutions below

0
dhrushit raval On

It looks fine to me. You can try the other syntax -- one without cc.p. Although it should not make any difference.

It could be that some part of rest of the code has an issue. Check out this video for reference.