我正在开发一款使用游戏中心的多人游戏,我的问题是,当我现在按下游戏并对其他设备执行相同操作时,游戏中心进行匹配并最终正确结束,但是当我向玩家发送邀请时它只是停留在等待和连接......
它永远不会将发起的玩家与受邀玩家联系起来。
任何解决方案?
先谢谢!!
- (void)addInvitationHandler{
GlobalController *gc = [GlobalController shared];
[GKMatchmaker sharedMatchmaker].inviteHandler = ^(GKInvite *acceptedInvite, NSArray *playersToInvite) {
// Insert application-specific code here to clean up any games in progress.
if (acceptedInvite)
{
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:acceptedInvite] autorelease];
mmvc.matchmakerDelegate = gc.renderer;
[gc.renderer matchmakerShow:mmvc];
}
else if (playersToInvite)
{
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2;
request.maxPlayers = 2;
request.playersToInvite = playersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = gc.renderer;
[gc.renderer matchmakerShow:mmvc];
}
};
}
这是我用来接受邀请和发送邀请的代码。