The default number of players in a turn-based game? (OS X)

Q: How to set the default number of players?


. Let me create a GKTurnBasedMatchmakerViewController with a matching request:

GKMatchRequest *request = [GKMatchRequest new]; request.minPlayers = 2; request.maxPlayers = [GKMatchRequest maxPlayersAllowedForMatchOfType:GKMatchTypeTurnBased]; request.defaultNumberOfPlayers = 2; GKTurnBasedMatchmakerViewController *controller = [GKTurnBasedMatchmakerViewController.alloc initWithMatchRequest:request]; controller.turnBasedMatchmakerDelegate = self; [GKDialogController sharedDialogController].parentWindow = self.view.window; [[GKDialogController sharedDialogController]presentViewController:controller]; 

Expected: 2 players by default

Expected

Actual: 16 players by default

Actual

GKMatchRequest Class Reference

The GKMatchRequest object is used to specify parameters for a new match in real time or in turn. You initialize the match request object, then pass it to another object to actually create a match. The type of object you pass depends on what type of match you need and whether you want to display the standard dating user interface.

https://developer.apple.com/library/mac/#documentation/GameKit/Reference/GKMatchRequest_Ref/Reference/Reference.html

 @property(nonatomic, assign) NSUInteger defaultNumberOfPlayers 

By default, the number of players for a match.

If this property is not set, then by default the number of players is equal to the value stored in the maxPlayers property. The default number of players determines the number of invitees shown in the standard dating user interface. The player can select an override to add or remove slots.

+4
source share
1 answer

Set defaultNumberOfPlayers to the value you want. In this case, it is set in accordance with the minimum number of players.

 - (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController { if (!gameCenterAvailable) return; presentingViewController = viewController; GKMatchRequest *request = [[GKMatchRequest alloc] init]; request.minPlayers = minPlayers; request.maxPlayers = maxPlayers; request.defaultNumberOfPlayers = minPlayers; GKTurnBasedMatchmakerViewController *mmvc = [[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request]; mmvc.turnBasedMatchmakerDelegate = self; mmvc.showExistingMatches = YES; [presentingViewController presentViewController:mmvc animated:YES completion:nil]; } 
0
source

Source: https://habr.com/ru/post/1490345/


All Articles