gpt4 book ai didi

macos - 回合制游戏的默认玩家人数? (操作系统)

转载 作者:行者123 更新时间:2023-12-03 00:28:59 27 4
gpt4 key购买 nike

问:我们如何设置默认玩家数量?

<小时/>

让我们创建一个带有匹配请求的 GKTurnBasedMatchmakerViewController:

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];

预期:2 个默认玩家

Expected

实际:16 位默认玩家

Actual

GKMatchRequest 类引用

GKMatchRequest 对象用于指定新的实时或回合制比赛的参数。您初始化一个匹配请求对象,然后将其传递给另一个对象以实际创建匹配。您传递给的对象类型取决于您想要哪种类型的匹配以及是否要显示标准匹配用户界面。

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

@property(nonatomic, assign) NSUInteger defaultNumberOfPlayers

比赛的默认玩家人数。

如果未设置此属性,则默认玩家数量等于 maxPlayers 属性中存储的值。默认玩家数量决定了标准匹配用户界面中显示的受邀者数量。玩家可以选择覆盖此设置以添加或删除插槽。

最佳答案

defaultNumberOfPlayers设置为您想要的值。在本例中,它被设置为匹配最小玩家数量。

- (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];
}

关于macos - 回合制游戏的默认玩家人数? (操作系统),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17532617/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com