The story on positioning
SpriteKit uses a grid of points to position nodes. In this grid, the bottom left corner of the scene is (0,0), with a positive x-axis to the right and a positive y-axis to the top.
Similarly, on the individual sprite level, (0,0) refers to the bottom left corner of the sprite, while (1,1) refers to the top right corner.
Alignment with anchor points
Each sprite has an anchorPoint
property, or an origin. The anchorPoint
property allows you to choose which part of the sprite aligns to the sprite's overall position.
Note
The default anchor point is (0.5,0.5), so a new SKSpriteNode
centers perfectly on its position.
To illustrate this, let's examine the blue square sprite we just drew on the screen. Our sprite is 50 points wide and 50 points tall, and its position is (150,150). Since we have not modified the anchorPoint
property, its anchor point is (0.5,0.5). This means the sprite will be perfectly centered over the (150,150) position on the scene's grid. Our sprite's left...