iphone - iOS 开发 : How do I auto match players in Game Center?

标签 iphone ipad ios gamekit game-center

我的应用程序中有一个“立即玩”按钮,允许玩家与其他随机玩家自动匹配。也许我在文档的某个地方遗漏了这个,但是我该如何编写代码来自动匹配玩家呢?

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/

相关文章:

ios - 多个帐户订阅的应用内购买

ios - 如何在 iOS 设备上调整图像大小?

ios - 在 Swift 中从 Tableviewcell 中关闭 Popover ViewController

iphone - 启用 iCloud 后,iOS 应用程序在首次启动时卡住

iphone - 出现异常 "message sent to deallocated instance"

iphone - 与弗兰克和 cucumber 一起复制资源

ios - stringByAddingPercentEscapesUsingEncoding : and stringByReplacingPercentEscapesUsingEncoding: 之间有什么区别

iphone - 在 FlipsideViewController 中设置 UISwitch 时遇到问题

iphone - ipad 应用程序在 ipad 上完美运行但在模拟器中运行不完美,这是一个不好的迹象吗?

ios - Xcode 不使用 IOS 8 SDK 合成属性