iOS开发:如何在Game Center中自动匹配玩家? [英] iOS Development: How do I auto match players in Game Center?

查看:342
本文介绍了iOS开发:如何在Game Center中自动匹配玩家?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a "Play Now" button in my app that allows players to be auto-matched with other random players. Maybe I'm missing this somewhere in the docs, but how do I write the code to auto match players?

Game Center沙盒服务器在最近几天搞砸了,所以我很难尝试不同的东西,因为我必须猜测,因为Game Kit docs对于如何做到这一点并不十分清楚。目前,我有代码设置(但未经测试)与朋友创建匹配...

The Game Center sandbox server has been messed up the last few days, so I'm having a hard time trying different things since I have to guess because the Game Kit docs aren't exactly clear on how to do this. Currently, I have code setup (but untested) 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
    }
}];

但是如何自动匹配两个寻找游戏的随机人?我的猜测,因为文档没有说出来,或者我错过了,就是为了创建一个自动匹配,我只需设置 playersToInvite 属性匹配对象为零?如果没有,我该如何创建一个自动匹配?

But how do I auto match two random people looking for a game? My guess, since the docs don't say it, or I'm missing it, is that in order to create an auto match, I simply set the playersToInvite property of the match object to nil? If not, how do I create an auto match?

另一个问题,当我们讨论这个主题时,Game Kit docs网站有几个常见的配对方案,一个他们是...

One other question, while we're on the topic, the Game Kit docs site a few common matchmaking scenarios, one of them being...


玩家还可以使用Game Center
应用程序创建网络
匹配。当他们邀请朋友
进入多人游戏时,您的
应用程序将在两个
设备上启动,并且
应用程序的每个副本都会收到
的邀请加入游戏。

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应用程序的任何地方都没有看到任何按钮。

But I can't figure out how to do this in the Game Center app for testing purposes. How does a user create a network match using the Game Center app? I don't see any buttons for that anywhere in the Game Center app.

提前感谢您的智慧!

推荐答案

好的,现在沙盒游戏中心服务器已备份,我通过设置 playersToInvite 属性为nil,或者不是全部设置。

Ok, now that the sandbox Game Center server is back up, I was able to confirm that auto-matching works by setting the playersToInvite property to nil, or not setting it all.

这篇关于iOS开发:如何在Game Center中自动匹配玩家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆