3
votes

I am new to programming and I am trying to build a simple game using Swift and SpriteKit. It looks good now but I have a little problem to solve. How do I get from a SKScene (Game) to a UIViewController in the Storyboard?

My game looks like this. In the Storyboard i have 3 views (Main menu, About and Game Over) and 1 SKScene (Game). When the player clicks on the play button in the main menu he gets to the game SKScene. When the player fails I want to get to a new UIViewController where I can link 2 buttons (back to main menu and restart).

I don't know how to do this. I will also accept Objective-C if you don't know in Swift.

1
You need to devise a way for the SKScene to communicate with the UIViewController. Have a look at this answer: stackoverflow.com/a/22555881/2043580 - ZeMoon

1 Answers

1
votes

For others encountering this problem down the road:

self.view?.window?.rootViewController

will return a UIViewController object when called in a SKScene.