This code, intending to present the user with the UIViewController
"menu", instead greets them with a black screen.
let currentViewController:UIViewController=UIApplication.shared.keyWindow!.rootViewController!
let mymenu = menu()
currentViewController.present(mymenu, animated: true, completion: nil)
I'm transitioning from a SKScene
.
To present a
SKScene
from anotherSKScene
you should do for example :You don't need to retrieve your
currentViewController
because you have always access to theview
of yourscene
As explained to the comments below, there are various methods to call a function implemented to your game viewController, one could be to create a delegate/protocol as showed in this code:
GameScene example:
GameViewController example:
Output: