Coordinate system
Everything in a game built in Sprite Kit is related to nodes, and it follows a node tree structure where a scene is a root node and other nodes are child nodes of it. When we put a node in the node tree, it uses its position property to place it within the coordinate system provided by its parent.
As a scene is also a node, it is placed inside the view provided by the SKView
object. The code part which we deleted in viewDidLoad
, GameScene
, was added as a child in the SKView
object. A scene uses its parent SKView
object coordination system to render itself and the content within it. The coordinate system is the same as we learned in basic mathematics.
As the preceding diagram shows, if we move right from (0,0), then x will be positive, and negative if we move left from (0,0). If we move up from (0,0), then y will be positive, and negative if we move down from (0,0). Coordinate values are measured in points and when the scene is rendered, it will be converted to pixels.
All...