多人游戏 - 邀请朋友在接受邀请后仍然等待等待

时间:2012-01-17 08:23:27

标签: iphone game-center multiplayer

我正在开发一款使用游戏中心的多人游戏,我的问题是,当我现在按下游戏并对其他设备执行相同操作时,游戏中心进行匹配并最终正确结束,但是当我向玩家发送邀请时它只是停留在等待和连接......

它永远不会将发起的玩家与受邀玩家联系起来。

任何解决方案?

先谢谢!!

- (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];

        }
    };

}

这是我用来接受邀请和发送邀请的代码。

1 个答案:

答案 0 :(得分:0)

This blog post在这类问题上给了我很多帮助。