How do you disable the "Play Now" ballon from appearing in the GKMatchmakerViewController

StackOverflow https://stackoverflow.com/questions/23644959

  •  22-07-2023
  •  | 
  •  

Вопрос

I would like to prevent users from pressing the 'play now' balloon button because I don't want them to be able to auto-match.

I would like them to only be able to invite specific players in 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:^{}];
 }
Это было полезно?

Решение

Looks like there isn't a way. But the next best thing for me is to let people press 'play now' and then hit them with a message box that says 'No' - you have to invite people and that looks like this.

- (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;
    //...
  }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top