Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Can';在Swift的另一个ViewController中,无法从游戏场景访问方法_Ios_Swift - Fatal编程技术网

Ios Can';在Swift的另一个ViewController中,无法从游戏场景访问方法

Ios Can';在Swift的另一个ViewController中,无法从游戏场景访问方法,ios,swift,Ios,Swift,我试图在GameViewController中从我的游戏场景访问一个方法,但我得到了一个“在展开时意外发现零”错误 在游戏场景中,我有: class GameScene: SKScene { func pauseGame() { self.view!.paused = true // to pause the game } } 在GameViewController中,我有: class GameViewController: UIViewController {

我试图在GameViewController中从我的游戏场景访问一个方法,但我得到了一个“在展开时意外发现零”错误

在游戏场景中,我有:

class GameScene: SKScene {


func pauseGame()
{
    self.view!.paused = true // to pause the game

}

}
在GameViewController中,我有:

class GameViewController: UIViewController {


    var gscene = GameScene(fileNamed: "GameScene")

func pauseActionButton(pauseActionButton: PauseActionButton, didSelectItemAtIndex index: Int) {

    gscene!.pauseGame()

    print("paused! \(index)")
}

}

我遗漏了什么吗?

您的GSE为零。。。检查你的文件名。不应该是,它是GameSecene.swift我能说什么。。。?阅读文档:你的gscene是零。。。检查你的文件名。不应该是,它是GameSecene.swift我能说什么。。。?阅读文档: