Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to present a modal view in sprite kit?

How can I use Game Center or the GameKit Framework with a Sprite Kit Xcode template? In Sprite kit, it uses Scenes; but normally to view the leaderboards for example you need to "presentModalViewController" but that is not possible in SKView.

Thanks in advance!

like image 384
iDevMartin Avatar asked Oct 21 '13 20:10

iDevMartin


1 Answers

Smick pointed me in the right direction for a similar problem I was having. I needed to send a message to the main ViewController from my SKScene. This did it for me:

In your SKScene, import the ViewController

#import "MyViewController.h"

Then send it a message:

[(MyViewController *)self.view.window.rootViewController  myMethod];

You could try creating a method in the ViewController that opens the GameKit view for you, that is triggered from the SKScene. Thanks Smick!

like image 95
Scott Avatar answered Nov 15 '22 04:11

Scott