How to get from SKScene to UIViewController?

2020-06-25 04:11发布

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条回答
家丑人穷心不美
2楼-- · 2020-06-25 04:54

For others encountering this problem down the road:

self.view?.window?.rootViewController

will return a UIViewController object when called in a SKScene.

查看更多
登录 后发表回答