如何从SKScene转到UIViewController? [英] How to get from SKScene to UIViewController?
问题描述
我是编程新手,我正在尝试使用Swift和SpriteKit构建一个简单的游戏.现在看起来不错,但我要解决一些问题.如何从情节提要(Game)转到情节提要中的UIViewController?
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?
我的游戏看起来像这样.在情节提要中,我有3个视图(主菜单,关于和游戏结束)和1个SKScene(游戏).当玩家单击主菜单中的播放按钮时,他进入游戏SKScene.当播放器失败时,我想进入一个新的UIViewController,在其中可以链接2个按钮(返回主菜单并重新启动).
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).
我不知道该怎么做.如果您不熟悉Swift,我也会接受Objective-C.
I don't know how to do this. I will also accept Objective-C if you don't know in Swift.
推荐答案
对于其他在途中遇到此问题的人:
For others encountering this problem down the road:
self.view?.window?.rootViewController
在 SKScene
中调用时,
将返回 UIViewController
对象.
这篇关于如何从SKScene转到UIViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!