cmi cmi - 5 months ago 35
Swift Question

Understanding the SpriteKit scene coordinates

I have a simple square (SKSpriteNode), 100x100, initially their coordinates are (0,568)

initial step

I would like move their coordinate to (0,568), like below:

after move

I don't understand why in the assistant editor, the x coordinate is 70. It should be 50 no? (100/2)
It's not logical for me.

Answer

The position of the square is calculated looking at the center of the shape.

Why the center?

Because the anchor point of this SKSpriteNode is (0,5, 0,5).

Answer

So in the second image, where is the center?

As you can see it is distant from the left border of the scene and that distance is 70 points.