【发布时间】:2014-03-23 07:18:57
【问题描述】:
我正在通过游戏中心创建一个有 2 名玩家的实时多人游戏。
我按照 Ray Wenderlich 的游戏中心教程,尝试设置邀请好友。我就像苹果说的那样设置了回调:
if ([GKLocalPlayer localPlayer].isAuthenticated) {
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
NSLog(@"Received invite");
self.pendingInvite = acceptedInvite;
self.pendingPlayersToInvite = playersToInvite;
[self inviteReceived];
};
}
我什至测试了 block 属性是否真的被设置了。是的。
我在 iOS7 的沙盒中,有一个模拟器和一个 iPhone 5。我无法收到任何邀请(见截图)。我启用了通知中心,在设置中检查了接受邀请,但从未调用该块。不过随机匹配效果很好。
【问题讨论】:
标签: ios cocoa-touch game-center multiplayer