I develop an universal game using Sprite Kit Level editor on Xcode 8 beta 4.
My scene in the level editor does 750x3334. In my scene I have a background image, the background image is adjusted to the scene size.
Scene anchor point = (0,1) Top left
Background anchor point = (0,1) Top left.
I need a camera inside my scene.
I set a SKCameraNode with a scale (1,1), the position of the camera is the center of my scene.
To create the scene :
if let scene = GKScene(fileNamed: "GameScene") {
if let sceneNode = scene.rootNode as! GameScene? {
// Copy gameplay related content over to the scene
sceneNode.entities = scene.entities
sceneNode.graphs = scene.graphs
sceneNode.scaleMode = .aspectFill
if let view = self.view as! SKView? {
view.presentScene(sceneNode)
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
}
When the game is launched, my camera has to be set to have the top of the background equal to the top edge of the device.
To do that:
override func sceneDidLoad() {
camera?.position.y = -UIScreen.main.nativeBounds.size.height/2
}
For the iPhone 6, it works perfectly. For the iPhone 5, 6+, I have a blank area (out of the scene) at the top edge.
So maybe my logic is wrong...