Search code examples
iphoneios4cocos2d-iphone

Rotate CCSprite around a specific point?


How can I rotate a sprite around a specific point, instead of the center point?

CCSprite rotation or CCRotateTo action rotate around the center point.

I'm trying to rotate the image of a face. Rotating around the center (nose) does not look as good as rotating around a point slightly below the center (chin).

In Photoshop it's possible to change the anchor point for rotation. Can that be done in cocos2d-iphone?


Solution

  • The most obvious way would be to enlarge the size of your sprite.

    If the height is 50px, and the current center rotation point is the middle (25px) and you want it to be at say, 30px, just enlarge the canvas of your sprite in photoshop so that the image gained 10px of transparent space at the bottom.

    Hopefully this helps your problem, i've never seen an anchor point reference for rotation in cocos2d.