SKScene
needs to be added to an SKView
which is a subclass of UIView
. When you create the view controller, you can either set the view
property to be an SKView
or add an SKView
as a subview, then add your SKScene
to that SKView
via the presentScene:
method on SKView
. Here's an example on how you could achieve that:
import SpriteKit
class SomeViewController: UIViewController {
func viewDidLoad() {
super.viewDidLoad()
let sceneView = SKView(frame: view.frame)
let scene = SKScene()
// Do any other scene setup here
view.addSubview(sceneView)
sceneView.presentScene(scene)
}
}
Sorry if there are small syntactical errors. Didn't have a chance to test this and my memory of the SpriteKit API is hazy. Hope this helps!