【问题标题】:Game Center Stuck in invitation游戏中心卡在邀请中
【发布时间】:2016-04-29 02:15:38
【问题描述】:

我正在为iOS 开发cocos2dx 游戏,我已经集成了Game Center,但是当我向朋友发送邀请时,发送者没有收到接收者接受请求的响应,或者没有委托方法正在调用。我已经尝试了所有解决方案,但没有任何进一步的工作,如果有任何问题我可以分享代码:

GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.inviteMessage = @"Your Custom Invitation Message Here";

request.inviteeResponseHandler = ^(NSString *playerID, GKInviteeResponse response)
{
    if (response == GKInviteeResponseAccepted)
    {
        NSLog(@"DEBUG: Player Accepted: %@", playerID);
        // Tell the infrastructure we are don matching and will start using the match
    }
};

[[GKMatchmaker sharedMatchmaker] findMatchForRequest:request withCompletionHandler:^(GKMatch* match, NSError *error) {
    if (error)
    {
        //Invite has not been sent

          NSLog(@"Invitation has not been sent");
    }
    else if (match != nil)
    {
        //whatever you want to do when the receiver accepts the invite
        NSLog(@"Invitation has  been sent with match object = %@",match);

    }
}];
request.recipientResponseHandler= ^(GKPlayer *player, GKInviteeResponse response)
{


    switch (response) {
        case GKInviteeResponseAccepted:
        {
        }
            break;
        case GKInviteeResponseDeclined:
        {

        }
            break;
        case GKInviteeResponseFailed:
        {

        }
            break;
        case GKInviteeResponseIncompatible:
        {

        }
            break;
        case GKInviteeResponseUnableToConnect:
        {


        }
            break;
        case GKInviteeResponseNoAnswer:
        {


        }
            break;

        default:
            break;
    }

};

GKMatchmakerViewController *mmvc =
    [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.matchmakerDelegate = self;

[viewController presentViewController:mmvc animated:YES completion:nil];

【问题讨论】:

  • 你收到任何 GKInviteeResponse 了吗?

标签: ios cocos2d-x game-center game-development


【解决方案1】:

这并不是真正的解决方案,但它是一种解决方法。就我而言,我最多有 4 名玩家,最少有 2 名玩家。如果我向 1 名玩家发送了邀请,而将其他 2 个空位留给 Apple 随机填充,它将永远不会进行。我发现推动事情的唯一方法是在发送邀请之前通过在空槽上点击 X 来移除空槽。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多