当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - Move from UIViewController to SKcene

问题描述:

I need help moving from a UIViewController that appears after launch. It is sort of a fake splash screen that is animated and I want it to change to the SKScene once done. I have tried using this,

let skView = self.view as SKView

var loading:LevelOne = LevelOne(size: skView.bounds.size)

var loadingScreen:SKView = self.view as SKView

skView.showsFPS = true

skView.showsNodeCount = true

skView.showsPhysics = true

loadingScreen.ignoresSiblingOrder = true

loadingScreen.presentScene(loading)

But I get a log with (lldb) and it marks out

let skView = self.view as SKView

and says the app crashes due to that. What am I doing wrong and is there anybody who can help me out? I can convert Objective-c (simple that is) but I will prefer it in Swift

Thanks!

网友答案:

How can you build you game with this line?

let skView = self.view as SKView

Because you can not downcast from SKView? to SKView. I think it should be

let skView = self.view as SKView!

One another, can you go to storyboard, check the view of ViewController. The view should be an instance of SKView instead of UIView as a normal application (You can see it in "Custom Class" session of "Show the identity inspector")

分享给朋友:
您可能感兴趣的文章:
随机阅读: