Can';t在iPhone/IOS 5上使用[GKMatchmaker addPlayersToMatch]添加其他玩家
我有一个游戏中心应用程序。我成功连接了两个客户端并可以发送消息等。我现在正尝试添加一个第三/第四个客户端,使用Can';t在iPhone/IOS 5上使用[GKMatchmaker addPlayersToMatch]添加其他玩家,iphone,ios,center,Iphone,Ios,Center,我有一个游戏中心应用程序。我成功连接了两个客户端并可以发送消息等。我现在正尝试添加一个第三/第四个客户端,使用[GKMatchmaker addPlayersToMatch]像这样 - (void) findAdditionalPlayer { GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease]; request.minPlayers = 2; // minPlayers = 3 doesn
[GKMatchmaker addPlayersToMatch]
像这样
- (void) findAdditionalPlayer
{
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = 2; // minPlayers = 3 doesn't work either
request.maxPlayers = 4;
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:match matchRequest:request completionHandler:^(NSError *error)
{
if (error)
{
// Process the error.
NSLog(@"Could not find additional player - %@", [error localizedDescription]);
}
else
{
NSLog(@"Find additional player expecting = %d", match.expectedPlayerCount);
}
}];
}
如果一个客户端(投票服务器)调用findAdditionalPlayer
,我将无法连接(另一个客户端正在使用GKMatchmakerViewController
)。奇怪的是,如果两个连接的客户端都调用了findAddtionalPlayer
,那么我的完成块将执行(match.expectedPlayerCount==2)
,但我的第三个客户端从未连接
应该只有一个游戏客户端调用上面的函数吗?文档并没有具体说明
有没有人举过使用addPlayersToMatch的例子?根据我的经验,对于2人游戏,addPlayersToMatch应该由两名玩家执行,以便他们重新连接到游戏(并通过游戏中心来回通信) 如果您的两个客户端都调用findAdditionalPlayer,则可以连接,因为它们都调用AddPlayerToMatch 如果您已经有一个有两名玩家(比如a和B)的游戏,并且您想要第三名玩家(比如C)加入,您必须: 在播放器A(邀请C)中: 在播放器B(邀请C)中: 在玩家C中(邀请A和B): 因此,重新加入或向比赛中添加新球员的机制似乎是:
玩家A、B和C各自使用一个match request对象执行AddPlayerToMatch调用,该对象的playerToInvite仅由D的playerID组成。当玩家D使用其playerToInvite数组包含a、B和C的玩家ID的match request对象执行其AddPlayerToMatch调用时。根据我的经验,对于一个2人游戏,两个玩家都应该执行AddPlayerToMatch,以便重新连接到游戏(并通过游戏中心来回通信) 如果您的两个客户端都调用findAdditionalPlayer,则可以连接,因为它们都调用AddPlayerToMatch 如果您已经有一个有两名玩家(比如a和B)的游戏,并且您想要第三名玩家(比如C)加入,您必须: 在播放器A(邀请C)中: 在播放器B(邀请C)中: 在玩家C中(邀请A和B): 因此,重新加入或向比赛中添加新球员的机制似乎是:
玩家A、B和C各自使用一个match request对象执行AddPlayerToMatch调用,该对象的playerToInvite仅由D的playerID组成。当播放器D使用其playerToInvite数组包含的match request对象执行AddPlayerToMatch调用时,B以及C的玩家ID。我遇到了4个玩家在玩的问题。如果1个玩家断开连接,那么其他3个玩家也断开连接。是的。如何克服这种情况。我遇到了4个玩家在玩的问题。如果1个玩家断开连接,那么其他3个玩家也断开连接。是的。如何克服这种情况。
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 3;
request.maxPlayers = 4;
request.playersToInvite = [NSArray arrayWithObject:playerC_id];
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:myMatch matchRequest:request completionHandler:nil];
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 3;
request.maxPlayers = 4;
request.playersToInvite = [NSArray arrayWithObject:playerC_id];
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:myMatch matchRequest:request completionHandler:nil];
GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 3;
request.maxPlayers = 4;
request.playersToInvite = [NSArray arrayWithObjects:playerA_id, playerB_id, nil];
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:myMatch matchRequest:request completionHandler:nil];