Creating a scene
When we create a scene, we can define many of its properties such as size, origin, and so on. as we require in our game. A scene size defines the visible area in the SKView object. Of course, we can put nodes outside this area, but they will be totally ignored by the renderer.
However, if we try to change the position property of a scene, it will be ignored by Sprite Kit because a scene is a root node in a node tree, its default value is CGPointZero
. But we can move scene origin by the anchorPoint
property. Default value for anchorPoint
is (0.5,0.5)
, which indicates the center point of the screen. By reassigning a new anchorPoint
property, we can change the coordinate system for its child. For example, if we set anchorPoint
to (0,0)
, the child node of the scene will start from the bottom left of the scene.
If we make the anchorPoint (0.5, 0.5)
or the middle of the screen, the child node of the scene will start from the middle of the screen. It totally depends on us and what...