繁体   English   中英

从UIViewController呈现SKScene-Swift

[英]Present SKScene from UIViewController - Swift

我想使用UIViewController作为菜单,使用SKScene作为GameScene进行游戏。

当玩家按下菜单上的“播放”按钮时,我想在菜单和GameScene之间进行以下转换:

let nextScene = GameViewController()
self.presentViewController(nextScene, animated: true, completion: nil)

但是我得到了这个错误:

Could not cast value of type 'UIView' (0x19ff623e0) to 'SKView' (0x19f813e70).

请问我该怎么做?

你里面的代码GameViewController正试图把self.view作为SKView但它实际上是一个UIView

您将需要在情节提要/ xib中将views类设置为SKView ,或者在视图控制器的loadView方法中自行创建。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM