iOS spriteKit child nodes position with respect to view coordinates

blitzeus picture blitzeus · Feb 18, 2014 · Viewed 9.9k times · Source

I have a child node added to another node. I want to get the child nodes position with respect to the views coordinates and not the parent nodes coordinates

Answer

rickster picture rickster · Feb 19, 2014

Get the child node's position with respect to its parent, then use the convertPoint:fromNode: or convertPoint:toNode: method to convert from the parent node's coordinate system to the scene's coordinate system. (Remember, SKScene inherits from SKNode and is the root of the node hierarchy, so you can use it with either of those methods.) If you then need to work in the UIKit view coordinate space, use the scene's convertPointToView: method.