How do I move from a GameScene to another view?

i am trying to present another view from inside the GameScene class by doing like this:



let mainVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MainVC") as! MainViewController

self.present(mainVC, animated: true, completion: nil)



the compiler then tells me: "Value of type 'GameScene' has no member 'present'"



Why can't i present another view programmatically and how do i fix this problem?


Thanks to anyone who can help me.

Replies

You need to go "up" in the hierarchy. The SKScene belongs to a SKView, which is managed by a view controller. It's that view controller that would need to present mainVC.


Note that by default there is no reference from the view to the view controller, so you have to arrange a way for the game scene to find the view controller.