iOS 和游戏中心 - 为托管游戏选择好友
我正在尝试向我们的游戏添加游戏中心支持。它已经支持 OpenFeint,但我们还想支持 GC。
基本的身份验证和使用非常简单,并且似乎运行得很好(除了沙箱非常不稳定)。然而,由于我们的架构,我们希望主要使用 GC 来挑选朋友,而不是使用完整的邀请支持。因此,我正在寻找一种方法,使用 GKMatchmakerViewController 之类的工具来仅挑选朋友,而不是向他们发送邀请。我想显示普通视图,其中玩家可以选择朋友,然后返回所选的朋友,我不希望视图/GC 向所选的朋友发送任何内容。
GKMatchmakerViewController * mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = my_delegate;
mmvc.hosted = YES;
根据文档,这应该调用我的委托的 didFindPlayers 方法,但它似乎不起作用。无论有还是没有,hosted 标志都没有效果,GC 似乎尝试向选定的朋友发送一些内容,然后在 UI 中短暂显示文本不兼容并忽略所选择的朋友。
我在这里做了什么根本错误的事情还是我想做的事情根本不可能实现? 不兼容错误实际上意味着什么?我在两台 iPad 之间运行,两台 iPad 都登录了沙盒用户。在不通知好友的情况下选择好友真的可能吗?
编辑:
当我尝试选择朋友时,GKMatchmakerViewController 显示的不兼容消息很奇怪。我还没有找到任何关于它可能意味着什么以及可能导致它的原因的文档。一个简单的猜测是,GC 以某种方式认为沙盒用户安装了我的游戏的不同版本,并且这些版本在某种程度上不兼容。该游戏已在应用商店中提供,但没有 GC 网络。沙箱环境能否以某种方式从中获取一些信息?不过,游戏垫上没有安装旧版本的游戏。
I'm experimenting with adding Game Center support to our game. It already has OpenFeint support but we'd also want to support GC.
The basic authentication and usage is quite easy and seems to work quite well (apart from that the sandbox is terribly unstable). However, due to our architecture we would like to use GC mainly for picking friends, not using the full invitation support. So, I'm looking for a way to use something like GKMatchmakerViewController to only pick friends, not send invites to them. I'd like to show the normal view where the player can select the friends and then just return the picked friends, I don't want the view/GC to send anything at all to the picked friends.
GKMatchmakerViewController * mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = my_delegate;
mmvc.hosted = YES;
This should according to the docs call my delegate's didFindPlayers method, but it doesn't seem to work. The hosted flag has no effect, both with and without it GC seems to try to send something to the picked friend(s) and then briefly shows a text Incompatible in the UI and and disregard the picked friend.
Do I do something fundamentally wrong here or is what I want to do just not possible? What does the Incompatible error actually mean? I'm running between two iPads that both have sandboxed users logged in. Is picking friends without notifying them actually possible?
Edit:
The Incompatible message that the GKMatchmakerViewController shows when I try to pick friends is weird. I have not found any documentation as to what it might mean and what could cause it. A simple guess is that GC somehow thinks that the sandboxed users have different versions of my game installed and these are somehow not compatible. This game is already available in the app store, but without GC networking. Could the sandbox environment somehow pick up some information from that? No old version of the game is installed on the pads though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于那些仍然遇到此问题的人。查看您的构建阶段,运行脚本部分。就我而言,我使用了其中一个自动增加构建号的脚本,这是跟踪此类事情的常见做法。但是,Game Center 不会接受这种方法。该脚本实际上采用 CFBundleVersion 并将其增加 1(有多种技术,我使用的只是 +1)。
所以我在 iPhone 上安装构建版本,它的构建版本号是 295,然后我在 iPad 上安装它,它有 296 构建版本,与捆绑版本相同。从 Game Center 的角度来看,这两个版本是不兼容的。
正常(即时)多人游戏模式在尝试邀请朋友时只会显示“不兼容”。回合制模式根本不会显示任何有用的东西。
整个事情很令人困惑,因为在游戏中心兼容性列表中的 iTunesConnect 上,它显示短版本字符串(CFBundleShortVersionString),所以我假设只要在项目设置的“版本”字段中输入相同的值,它就会起作用。但事实并非如此,“构建”也必须相同。
To those who still experience this issue. Take a look at your build phases, Run Script section. In my case I used one of these scripts that automatically increases build number, its a common practice to keep track of such things. But, Game Center will not get along with this approach. The script actually takes CFBundleVersion and increases it by 1 (there are various techniques, the one I use just does +1).
So I install build on iPhone, it's build number is, say, 295, then I install it on iPad and it has 296 build version, which is same as bundle version. And the two versions are incompatible from Game Center's point of view.
The normal (instant) multiplayer mode just says "Incompatible" when trying to invite a friend. Turn-Based mode will not show anything useful at all.
The whole thing is confusing, since on iTunesConnect in Game Center compatibility list it shows short versions strings (CFBundleShortVersionString), so I assumed as soon as I put same value in "Version" field of project settings, it will work. It doesn't though, the "Build" must be same as well.
我可以确认 Info.plist 中的 CFBundleVersion 必须完全匹配。我的一台设备版本为“4.00”,另一台设备版本为“4.0”,但我收到了“不兼容”消息。将它们都更改为“4.00”解决了该问题。
I can confirm that the CFBundleVersion in the Info.plist must match exactly. I had one device with version "4.00" and the other one at "4.0", and I was getting the 'Incompatible' message. Changing them both to "4.00" resolved the issue.