Reputation: 59
How can I call my showLeader() function from GameViewController.swift in GameScene.swift ? this is my showLeader function
func showLeader() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
Upvotes: 2
Views: 241
Reputation: 1904
You make use of NSNotificationCenter to present the viewController from an SKScene. Remember to add the observer and then post the notification. Don't forget to deinit the NSNotification when you no longer need it or your app will crash.
Upvotes: 1