1

Is there some way to get a SKNode's zRotation relative to its scene rather than to its parent? Or even relative to any other SKNode?

Right now I'm doing this:

func rotationRelativeToSceneForNode(node: SKNode) -> CGFloat {
    var nodeRotation = CGFloat(0)
    var tempNode: SKNode = node

    while !(tempNode is SKScene) {
        nodeRotation += tempNode.zRotation
        tempNode = tempNode.parent!
    }

    return nodeRotation
}

But I'm not sure this is the best way to do it.

0x141E
  • 12,613
  • 2
  • 41
  • 54
Ivens Denner
  • 523
  • 5
  • 12
  • I don't think there is one single instruction that does what you want for rotations (there is one for converting points from one coordinate system to another, although it is useless in this case). Anyway, your way seems to be very good and fast already. – RoberRM Sep 30 '15 at 00:03
  • Yeah, I was looking for something like the one used for converting points. :/ – Ivens Denner Sep 30 '15 at 01:05

0 Answers0