你如何禁用"立即播放"气球出现在Matchmaker ViewController中

时间:2014-05-14 03:04:30

标签: ios game-center

我想阻止用户按下“立即播放”气球按钮,因为我不希望他们能够自动匹配。

我希望他们只能邀请游戏中心的特定玩家。

  if([GKLocalPlayer localPlayer].isAuthenticated)
  {
    if(!_matchRequest)
      _matchRequest                      = [[GKMatchRequest alloc] init];

    _matchRequest.minPlayers             = 2;
    _matchRequest.maxPlayers             = 2;
    _matchRequest.defaultNumberOfPlayers = _matchRequest.minPlayers;
            //prevent automatch players
    //how to disable 'play now' ?

    if(_mmvc)
      _mmvc = nil;

    _mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:_matchRequest];

    _mmvc.matchmakerDelegate = self;

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

1 个答案:

答案 0 :(得分:0)

看起来没有办法。但对我来说,下一个最好的事情就是让人们按下现在的游戏'然后用一个消息框点击它们,上面写着“没有' - 你必须邀请人,这看起来像这样。

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
  if(_matchRequest.playersToInvite == nil)
  {
    //This happens when the end-user presses 'play now'
    //Don't let them 'play now' - force them to invite one other device
    UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"No" message:@"You can't play now. You have to invite someone." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [v show];
  }
  else
  {
    //you invited someone - you can start the game
    _match = match;
    //...
  }