So I\'m developing a game on Xcode using Spritekit, for the iPhone. And it looks all the same and great on all iPhone devices, by using the node.setScale() method. Now I wan
You basically have 2 options.
1) Set scene size to 1024X768 (landscape) or 768x1024 (portrait) and use the default .aspectFill for scale mode. This was the default setting in Xcode 7 (iPad resolution).
You than usually just show some extra background at the top/bottom (landscape) or left/right (portrait) on iPads.
Examples of games that show more on iPads:
Altos Adventure, Leos Fortune, Limbo, The Line Zen, Modern Combat 5.
2) Apple changed the default scene size in xCode 8 to iPhone 6/7 (750*1334-Portait, 1337*750-Landscape). This setting will crop your game on iPads.
Chosing between the 2 options is up to you and depends what game you are making. I usually prefer to use option 1 and show more background on iPads.
Regardless of scene size scale mode is usually best left at the default setting of .aspectFill or .aspectFit
To adjust specific things such as labels etc for a device you can do it this way
if UIDevice.current.userInterfaceIdiom == .pad {
// adjust some UI for iPads
}
I would not try to do some random hacks where you manually change scene or node sizes/scales on difference devices, you should let xCode/SpriteKit do it for you.
Hope this helps
If you are using SKCameraNode
then you can scale the entire scene by scaling the camera.
// SKCameraNode+Extensions.swift
extension SKCameraNode {
func updateScaleFor(userInterfaceIdiom: UIUserInterfaceIdiom) {
switch userInterfaceIdiom {
case .phone:
self.setScale(0.75)
case .pad:
self.setScale(1.0)
default:
break
}
}
}
Then call it when your scene initializes.
guard let camera = self.childNode(withName: "gameCamera") as? SKCameraNode else {
fatalError("Camera node not loaded")
}
// Update camera scale for device / orientation
let userInterfaceIdiom = UIDevice.current.userInterfaceIdiom
camera.updateScaleFor(userInterfaceIdiom: userInterfaceIdiom)