Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在游戏中心找不到玩家。我测试我的游戏错了吗?_Ios_Game Center_Gkmatchmaker - Fatal编程技术网

Ios 在游戏中心找不到玩家。我测试我的游戏错了吗?

Ios 在游戏中心找不到玩家。我测试我的游戏错了吗?,ios,game-center,gkmatchmaker,Ios,Game Center,Gkmatchmaker,我在Xcode模拟器和iPhone上运行游戏。当我点击搜索时,它们都被放在不同的游戏中,而不是一个玩家加入现有的游戏。这是一款回合制游戏,玩家可以在游戏中心自动运行时进行第一回合。我使用的是两个单独的游戏中心帐户,沙箱设置为on。知道我做错了什么吗?对于那些开发了游戏中心支持的游戏的人,您是如何测试它的?谢谢你的帮助 一些代码: - (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers // view c

我在Xcode模拟器和iPhone上运行游戏。当我点击搜索时,它们都被放在不同的游戏中,而不是一个玩家加入现有的游戏。这是一款回合制游戏,玩家可以在游戏中心自动运行时进行第一回合。我使用的是两个单独的游戏中心帐户,沙箱设置为on。知道我做错了什么吗?对于那些开发了游戏中心支持的游戏的人,您是如何测试它的?谢谢你的帮助

一些代码:

- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers // view controller calls to find match - nothing if GC unavaiable
             viewController:(UIViewController *)viewController {


if (!_enableGameCenter) return;


_matchStarted = NO; // Match not started yet
self.currentMatch = nil;
[viewController dismissViewControllerAnimated:NO completion:nil];

GKMatchRequest *request = [[GKMatchRequest alloc] init]; // Set number of players
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;

GKTurnBasedMatchmakerViewController *mmvc = // new instance of the GKMatchmakerViewController with the given request, sets its delegate to the GameKitHelper object, and uses the passed-in view controller to show it on the screen. Shows the user to search for a random player and start a game.
[[GKTurnBasedMatchmakerViewController alloc] initWithMatchRequest:request];
mmvc.turnBasedMatchmakerDelegate = self;

[viewController presentViewController:mmvc animated:YES completion:nil];
}

#pragma mark GKTurnBasedMatchmakerViewControllerDelegate

// A peer-to-peer match has been found, the game should start
- (void)turnBasedMatchmakerViewController:(GKTurnBasedMatchmakerViewController *)viewController didFindMatch:(GKTurnBasedMatch *)match {
[viewController dismissViewControllerAnimated:YES completion:nil];
self.currentMatch = match;
GKTurnBasedParticipant *firstParticipant = [match.participants objectAtIndex:0];
if (firstParticipant.lastTurnDate == NULL) {
    // It's a new game!
    [delegate enterNewGame:match];
} else {
    if ([match.currentParticipant.player isEqual:[GKLocalPlayer localPlayer].playerID]) {
        // It's your turn!
        [delegate takeTurn:match];
    } else {
        // It's not your turn, just display the game state.
        [delegate layoutMatch:match];
    }
    }
}

在开始/加入新测试的匹配项之前,您是否正在删除测试期间生成的部分已填充参与者列表中的旧匹配项?您可以手动从game center应用程序中删除旧比赛,或在代码中的适当时间使用
loadMatchesWithCompletionHandler
“加载涉及本地玩家的回合比赛,并为每场比赛创建一个比赛对象”,以识别要删除的比赛。请参阅苹果的文档,以确定正确离开、结束和删除比赛的步骤。

发布连接球员的代码。