我的应用程序中有一个“立即玩”按钮,允许玩家与其他随机玩家自动匹配。也许我在文档的某个地方遗漏了这个,但是我该如何编写代码来自动匹配玩家呢?
Game Center 沙盒服务器最近几天出现问题,所以我很难尝试不同的东西,因为我不得不猜测,因为 Game Kit 文档并不清楚如何做到这一点。目前,我有代码设置(但未经测试)来创建与 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
}
}];
但是我如何自动匹配两个正在寻找游戏的随机人?我的猜测是,由于文档没有说明,或者我遗漏了它,是为了创建自动匹配,我只是将匹配对象的 playersToInvite
属性设置为 nil 吗?如果没有,我该如何创建自动匹配?
另一个问题,当我们讨论这个话题时,Game Kit 文档网站提供了一些常见的配对场景,其中之一是......
A player can also create a network match using the Game Center application. When they invite a friend into a multiplayer game, your application is launched on both devices, and each copy of your application receives an invitation to join the game.
但出于测试目的,我不知道如何在 Game Center 应用程序中执行此操作。用户如何使用 Game Center 应用程序创建网络匹配?我在 Game Center 应用程序的任何地方都没有看到任何按钮。
提前感谢您的智慧!
最佳答案
好的,现在沙盒 Game Center 服务器已备份,我可以通过将 playersToInvite
属性设置为 nil 或不全部设置来确认自动匹配有效。
关于iphone - iOS 开发 : How do I auto match players in Game Center?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4629203/