如何解雇SKScene? [英] How to dismiss SKScene?

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

问题描述

在即时通讯与我SKScene完成是有办法从我SKScene类中驳回SKScene?

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

如果在我的viewController没有回来,我提出我的SKScene [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];
}


推荐答案

你不能去从场景返回视图控制器。场景是视图,视图控制器控制并显示视图。使用视图控制器更改视图。记住视图控制器本身不是视图。 -Wharbio

"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

此处的最佳解决方案是创建另一个View Controller。这个视图控制器将是我的菜单。那么其他的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天全站免登陆