iOS游戏工具包基于回合的比赛编程重赛 [英] iOS Game Kit Turn Based Match Programatic Rematch

查看:143
本文介绍了iOS游戏工具包基于回合的比赛编程重赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用游戏中心和GKTurnbasedMatch的2人,iOS回合制游戏。

I have a 2-player, iOS turn-based game that uses the game center and GKTurnbasedMatch.

有没有办法在比赛后以编程方式重新匹配对手已完成?

Is there a way to programmatically rematch an opponent after a match has finished?

我想让玩家一键式访问彼此开始新的比赛。

I would like to give the players one-button access to starting a new match with each other.

如果没有一键式方法,有哪些潜在的替代方案?

If there is not a one button approach, what are some potential alternatives?

推荐答案

确实它出现了游戏中心正在忽略完整的程序化解决方案。毫无疑问是一种痛苦。在@selector(doRematchTap)中尝试以下内容......或等效的:

Indeed it appears a full programmatic solution is being ignored by Game Center. A pain, no doubt. Try the following in your @selector(doRematchTap)... or some equivalent:

    NSMutableArray *playerIds = [NSMutableArray array];
    GKTurnBasedParticipant *otherPlayer = /* Get the other player some way */;
    GKTurnBasedParticipant *myParticipant = /* Get yourself a very similar way*/;

    [playerIds addObject:myParticipant.playerID];
    if (otherPlayer.playerID) {
        [playerIds addObject:otherPlayer.playerID];
    }// sanity check

    GKMatchRequest *request = [[GKMatchRequest alloc] init];
    request.playersToInvite = playerIds;
    request.minPlayers = 2;
    request.maxPlayers = 2;

    GKTurnBasedMatchmakerViewController *tbmcv = [[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request];
    tbmcv.showExistingMatches = NO;
    tbmcv.turnBasedMatchmakerDelegate = /* Your normal delegate for the callbacks */;

    [self presentViewController:tbmcv
                       animated:YES
                     completion:^{
                      }];

重要的是要注意showExistingMatches = NO,它会将视图控制器直接跳转到匹配模式并且正确用户预先选择(似乎),并且不显示用户现有的匹配。

Important to note the showExistingMatches = NO, which will jump the view controller right into matchmaking mode with the correct user pre-selected (it seems), and not show the user's existing matches.

这篇关于iOS游戏工具包基于回合的比赛编程重赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆