Reputation: 1008
I would like to make a game using a UIViewController for the Menu and a SKScene for the GameScene.
When the player press the Play button on the Menu, I would like a transition between the Menu and the GameScene with something like :
let nextScene = GameViewController()
self.presentViewController(nextScene, animated: true, completion: nil)
But I got this error :
Could not cast value of type 'UIView' (0x19ff623e0) to 'SKView' (0x19f813e70).
How can I do this please ?
Upvotes: 1
Views: 654
Reputation: 13296
Your code inside of GameViewController
is trying to treat self.view
as a SKView
but its actually a UIView
.
You will either need to set the views class to SKView
in the storyboard/xib or create it yourself in your view controllers loadView
method.
Upvotes: 2