Drakalex Drakalex - 1 month ago 22
Swift Question

SKCameraNode not centered

I'm working with Swift 3, Xcode and SpriteKit

I have a SKCameraNode named cam, and I put a node at the camera's position to check it:

var cam: SKCameraNode!
let cameraNode = SKSpriteNode(imageNamed: "hx")

override func didMove(to view: SKView)
cam = SKCameraNode()
camera = cam
cam.position = CGPoint(x: playableRect.midWidth, y: playableRect.midHeight)


And here's what I got :

The red line is the limit of my playableRect.
The white hexagon is the position of the camera. We can clearly see that the camera right in the center of my playableRect as I wanted, but normally this camera should be in the center of the screen, why is it on the left ?
I mean, normally my cameraNode should always be at the center of the screen, it seems logic.


Can you help me ?


Set the scene anchor point to (0.5,0.5)