I have one viewController called NeighborhoodViewController. It loads a scene into the viewController, called NeighborhoodScene.sks. This works absolutely fine. I have rigged up a segue from a specific node in the scene through NeighborhoodViewController. These two functions control this:
func createSegue(title: String) {
performSegueWithIdentifier(title, sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let viewController: SearchViewController = segue.destinationViewController as? SearchViewController {
viewController.sceneName = "game_1_1"
}
}
This all works fine. The segue is being called. The segue is meant to bring up another VC called SearchViewController, which is supposed to bring up its own scene, SearchScene1.sks.
This is the code for that:
import UIKit
import SpriteKit
class SearchViewController: UIViewController {
var sceneName: String?
var chosenScene: GameScene?
override func viewDidLoad() {
super.viewDidLoad()
if sceneName == "game_1_1" {
chosenScene = GameScene(fileNamed: "SearchScene1")
} // TODO: add the rest of the presented scenes here
if let scene = chosenScene {
// Configure the view.
let skView = self.view as! SKView
skView.showsPhysics = true
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = false
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
scene.viewController = self
skView.presentScene(chosenScene)
}
}
}
If I print out the restorationidentifier for skView, it pertains to the view within the SearchViewController, which is perfect. It all seems to be working fine until skView.presentScene(chosenScene) at which point it randomly seems to be setting up NeighborhoodViewController? How do I make it call up SearchViewController and the associated sks scene -- SearchScene1?