How to get from SKScene to UIViewController?

自古美人都是妖i 提交于 2019-12-21 05:39:14

问题


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:


For others encountering this problem down the road:

self.view?.window?.rootViewController

will return a UIViewController object when called in a SKScene.



来源:https://stackoverflow.com/questions/25304607/how-to-get-from-skscene-to-uiviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!