I'm trying to figure out how to add more scenes in SpriteKit. If I use the line generated from SpriteKit in the GameViewController
if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene
This works fine, however if I create a class that's also a of type SKScene and add it the the SKView.
let newscene = GameMenu()
skView.presentScene(newscene)
This will not work. It just displays a washed out gray color with only a fraction of the nodes but nothing actually presented. Is there something going wrong with the way SpriteKit uses unarchiveFromFile to create the scene. I'm also not even using the Storyboard or GameScene.sks. The entire game has been created programatically. One more Issue if I try to create another ViewController for a menu and use presentViewController. When it tries to run I also get an error that says "Could not cast value of type 'UIView' to 'SKView.'" I'm casting it with the same line similar to GameViewController.
let skView = self.view as! SKView
This is the line that it keeps breaking on. If anyone has any insight on how to fix this problem that would be greatly appreciated.
initmethod ofGameMenulook like? Edit your question to include that code. - rob mayoff