Is SpriteKit coordinate system changed in Xcode 8?

In a previous version of SpriteKit, the start (0,0) was always in the lower left corner. In addition, Node added to their parents, by default, started there.

Starting with Xcode 8, it seems that the new beginning is by default in the center of the screen.

Is this the correct behavior, a bug in the beta, or am I just not understanding SpriteKit?

The same code is used as for

import SpriteKit import GameplayKit class GameScene: SKScene { override func didMove(to view: SKView) { let ship = SKSpriteNode(imageNamed: "Spaceship") addChild(ship) } } 

Xcode 7:

enter image description here

Xcode 8:

enter image description here

+6
source share
1 answer

No, SpriteKit still uses the same coordinate system.

The difference is that the .sks script file that comes with the new project has changed. In earlier versions of Xcode, this .sks file had its own reference point (that is, where the "origin" of the scene is) (0,0), which leads to the fact that the origin is in the lower left corner.

In Xcode 8, the .sks file has a default reference point (0.5, 0.5), which is the center of the scene.

To revert to the previous behavior, just go into this .sks file and reset the anchor point to (0,0). Any old .sks files that you were lying should still work, as their anchor points were set to (0,0) before.

+6
source

All Articles