0

I am doing a turn-based game and have a viewController were i set the parameters for the game and would like to jump directly to the Game Center invitation ViewController, se picture.

I have been looking for a solution for this but not been able to find any description of this.

My question is if it is possible?

enter image description here

PeterK
  • 4,243
  • 4
  • 44
  • 74

1 Answers1

0

If you have setup a GKTurnBasedMatchHelper class which includes a singleton sharedInstance class method you can call Game Center's auto match screen by doing the following:

[[GCTurnBasedMatchHelper sharedInstance]
     findMatchWithMinPlayers:2 maxPlayers:2 viewController:self];

The sharedInstance method in your GCTurnBasedMatchHelper should look like this:

+ (GCTurnBasedMatchHelper *) sharedInstance {
    static GCTurnBasedMatchHelper *sharedHelper;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedHelper = [[GCTurnBasedMatchHelper alloc] init];
    });

    return sharedHelper;
}

You can find a great tutorial on turn based gaming with Game Center in this article on turn based gaming with Game Center.

CodeGuru
  • 301
  • 2
  • 4