Skip to content

Instantly share code, notes, and snippets.

@lbehnke
Last active August 29, 2015 14:10
Show Gist options
  • Save lbehnke/4f5b5e16f6fb201abeb6 to your computer and use it in GitHub Desktop.
Save lbehnke/4f5b5e16f6fb201abeb6 to your computer and use it in GitHub Desktop.
Display SpriteKit view. In your storyboard, set the view's custom class to SKView.
import SpriteKit
class MySKScene: SKScene {
// implementation
}
import UIKit
import SpriteKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let skView = self.view as SKView
skView.showsFPS = true
skView.showsNodeCount = true
skView.ignoresSiblingOrder = true
let scene = MySKScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment