Xcode:不起作用执行SeguewithIdentifier

时间:2016-11-03 10:43:09

标签: swift xcode

照片:https://i.stack.imgur.com/CWz8B.png

我按下Game ViewController上的任意按钮,按钮上有一个标题确定关卡并加载它:

let sceneView = GameScene(fileNamed: "Level " + String(buttonTitle))
let skView = SKView(frame: self.view.frame)
self.view.addSubview(skView)
skView.showsFPS = true
skView.showsNodeCount = true
skView.ignoresSiblingOrder = true
sceneView!.scaleMode = .aspectFill
skView.presentScene(sceneView)

然后我可以在Segue的帮助下轻松进入主菜单:

if node.name == "menu"{
   self.viewController.performSegue(withIdentifier: "GoToMainMenu", sender: self)
   self.removeAllActions()
   self.removeAllChildren()
}

但是如果你去任何场景(任何级别)并使用重试按钮更新关卡:

if node.name == "retry" {
   let currentScene = GameScene(fileNamed: "Level "+String(thisScene))
   let transition = SKTransition.doorsCloseHorizontal(withDuration: 0.5)
   currentScene!.scaleMode = SKSceneScaleMode.aspectFill
   self.scene!.view?.presentScene(currentScene!, transition: transition)
} 

然后

if node.name == "menu"{
   self.viewController.performSegue(withIdentifier: "GoToMainMenu", sender: self)
   self.removeAllActions()
   self.removeAllChildren()
}

停止工作。仅适用于

   self.removeAllActions()
   self.removeAllChildren()

我不明白发生了什么。

0 个答案:

没有答案