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
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)