I do not know if this is really relevant, but I would like to present you a solution to this problem.
As you can see here Swift iOS: execute Segue from an instance in the ViewController to another ViewController I had the same problem some time ago that I managed to fix using Protocols .
The problem is that you can only call "performSegueWithIdentifier (" GameOver ", sender: nil) in your GameViewController class, but you would like to execute it from your game.
Therefore, you create the following protocol in your GameScene:
@objc protocol GameOverDelegate { func gameOverDelegateFunc() }
and the variable for the delegate in Gamescene:
var gamescene_delegate : GameOverDelegate?
in your GameViewController class you need to add a delegate to the class definition
class GameViewController: UIViewController, GameOverDelegate { ... }
and set the scene delegate to the viewDidLoad function of your GameViewController for yourself:
scene.gamescene_delegate = self
The final step is to implement the gameOverDelegateFunc () function in your GameViewController:
func gameOverDelegateFunc() { self.performSegueWithIdentifier("GameOver", sender: nil) }
That is all you have to do.
Whenever you want to execute this Segue in your GameScene, you just need to call the function through the delegate as follows:
gamescene_delegate?.gameOverDelegateFunc()
I hope everything is clear, and I could help,
Regards, Phil