如何关闭 SKScene? [英] How to dismiss SKScene?

查看:20
本文介绍了如何关闭 SKScene?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我完成我的 SKScene 时,有没有办法从我的 SKScene 类中关闭 SKScene?

When Im finished with my SKScene is there a way to dismiss the SKScene from within my SKScene class?

如果没有回到我展示 SKScene 的 Viewcontroller [skView presentScene:theScene]; 有没有办法重新启动场景或从我的 SKView 中删除?

If not back in my Viewcontroller where I present my SKScene [skView presentScene:theScene]; is there a way to restart the scene or remove in from my SKView?

SKScene 类参考SKView 类参考 没有帮助.

更新:

以下代码从我的 SKView 中删除我的场景 [yourSKView presentScene:nil]; 但是当我回到我的视图控制器时,场景仍在后台运行.我总是可以在游戏结束时暂停它,然后我被送回我的视图控制器(菜单),但我想知道还有其他方法可以暂停它,比如完全删除它?

The following code removes my scene from my SKView [yourSKView presentScene:nil]; but when Im back in my view controller the scene is still running in the background. I can always pause it when the game is over and I'm sent back to my view controller(menu) but I'm wondering is there another method other then pausing it like completely removing it?

-(void)endTheGame {
    [highscoreLabel removeFromSuperview];
    NSLog(@"Game Over");
   //would like to end here before calling the below method in my view controller
    [self.delegate mySceneDidFinish:self];
}

推荐答案

"你不能从场景中回到视图控制器".场景是一个视图,视图控制器控制并显示视图.使用视图控制器来改变视图.记住视图控制器本身不是视图."-沃比奥

"You can't go "Back to the View Controller" from a scene. The scene is a View, the view controller controls and displays views. Use the view controller to change views. Remember the view controller itself is not a view." -Wharbio

这里最好的解决方案是创建另一个视图控制器.这个视图控制器将是我的菜单.然后另一个 viewcontroller 将作为 skscene 的宿主.

Best solution here is to create another View Controller. This view controller will be my menu. Then the other viewcontroller will act as a host for the skscene.

在我的情况下,我然后使用我的菜单视图控制器关闭 skview 中显示的视图控制器.

In my situation I then use my menu viewcontroller to dismiss the viewcontroller displaying in the skview.

这篇关于如何关闭 SKScene?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆