I am working on a game for macOS using Spritekit. Want to use a second scene. How do I set up App Delegate and ViewController to accomplish that? I can make a transition to a second scene
var secondScene = SecondScene(size: self.size)
var transition = SKTransition.flipVertical(withDuration: 1.0)
secondScene.scaleMode = SKSceneScaleMode.aspectFill
self.scene!.view?.presentScene(secondScene, transition: transition)
Similar code in the SecondScene to return results in a crash during reloading of the previous scene, which loads fine the first time around.
self.scene!.view?.presentScene(FirstScene, transition: transition)
This is what my ViewController looks like.
class ViewController: NSViewController {
@IBOutlet var skView: SKView!
@IBOutlet weak var msg: NSTextField!
override func viewDidLoad() {
super.viewDidLoad()
if let view = self.skView {
// Load the SKScene from 'GameScene.sks'
if let scene = SKScene(fileNamed: "GameScene") {
// Set the scale mode to scale to fit the window
scene.scaleMode = .aspectFill
// Present the scene
view.presentScene(scene)
}
view.ignoresSiblingOrder = true
view.showsFPS = true
view.showsNodeCount = true
}
}
}