I'm working on a project, and SKNodes aren't resizing dynamically based on device size.
Example:
I'd like what happens on the first image to happen in the second. Is there anything to make this happen automatically?
Current sizing for image shown:
background.position = CGPoint(x: frame.size.width / 2, y: frame.size.height / 2)
background.size = CGSize(width: background.size.width / 5.5, height: background.size.height / 5.5)
GameViewController:
import UIKit
import SpriteKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Configure the view.
let skView = self.view as! SKView
skView.showsFPS = false
skView.showsNodeCount = false
let scene = GameScene(size: skView.bounds.size)
scene.controller = self
scene.size = skView.bounds.size
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return .AllButUpsideDown
} else {
return .All
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Release any cached data, images, etc that aren't in use.
}
override func prefersStatusBarHidden() -> Bool {
return true
}
}