Abdul Ahmad
Abdul Ahmad

Reputation: 10021

sprite anchor point for rotateToAngle

In sprite kit, how do I rotate a sprite from a position other than its center? does changing its anchor point have anything to do with this?

I'm using an action to perform the rotation:

let action = SKAction.rotateToAngle(1, duration: 0.1, shortestUnitArc: true)
node.runAction(action)

Upvotes: 0

Views: 66

Answers (1)

ABakerSmith
ABakerSmith

Reputation: 22939

Yes, you need to change the anchorPoint. The x and y of the anchorPoint can vary from 0 to 1, this image from Working With Sprites should help explain:

enter image description here

Upvotes: 1

Related Questions