Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to rotate a Node around an arbitrary point in SpriteKit?

Tags:

Is there a way to rotate a Node in SpriteKit around an arbitrary point? I now I can manipulate the anchorPoint of my Node, but that is not sufficient if the rotation point I want to use lies outside of the Node.

enter image description here

What is the best way to achieve this kind of rotation in SpriteKit?

like image 853
Ben-G Avatar asked Sep 27 '13 07:09

Ben-G


1 Answers

Since you're asking for the best way, here's one that works well (best is subjective):

Create an SKNode and set its position to the center of rotation. Add the node that should rotate around that center as child to the center node. Set the child node's position to the desired offset (ie radius, say x + 100). Change the rotation property of the center node to make the child node(s) rotate around the center point. The same works for cocos2d btw.

like image 178
LearnCocos2D Avatar answered Feb 08 '23 03:02

LearnCocos2D