IOS Development: how can I auto-reply players in Game Center?

I have a Play Now button in my application that allows players to automatically match with other random players. Maybe I missed it somewhere in the docs, but how do I write code for answering machines?

The Game Center sandbox server has been corrupted over the past few days, so it’s hard for me to work with it, because I have to guess, because in the Game Kit docs it’s not quite clear how to do this. I currently have a code setup (but not verified) to create a match with a friend ...

NSArray *playerList = [NSArray arrayWithObject:pid]; GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; request.minPlayers = 2; request.maxPlayers = 4; request.playersToInvite = playerList; [[self waitingIndicator] startAnimating]; [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch *match, NSError *error) { if (error) { //handle error } else if (match != nil) { self.myMatch = match; //start match code } }]; 

But how do I auto-answer two random people who are looking for a game? My guess, since the docs aren't talking about this, or I'm skipping it, is that to create an automatic match, I just set the playersToInvite property of the match object to nil? If not, how do I create an auto-match?

Another issue, while we're on the subject, the Game Kit documents the site with a few common collaboration scenarios, one of which ...

The player can also create a match network using the Game Center expression. When they invite a friend to a multiplayer game, your application runs on both devices and each copy of your application receives an invitation to join the game.

But I can’t figure out how to do this in the Game Center app for testing. How does a user create a network match using the Game Center app? I do not see any buttons for this in any Game Center application.

Thank you in advance for your wisdom!

+2
source share
1 answer

So now that the Game Center server for the sandbox is in backup, I was able to confirm that playersToInvite works by setting the playersToInvite property to zero or not setting it at all.

+2
source

Source: https://habr.com/ru/post/1501195/


All Articles