3

I'm working on a project, and SKNodes aren't resizing dynamically based on device size.

Example:

Image one enter image description here

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
}
}
Jordan Osterberg
  • 289
  • 3
  • 18

1 Answers1

1

If you want your whole scene to resize when the game is presented on device with a larger screen you just need to open GameViewController.swift and make sure you are using AspectFill

scene.scaleMode = .AspectFill
Luca Angeletti
  • 58,465
  • 13
  • 121
  • 148