【发布时间】:2014-03-19 06:06:30
【问题描述】:
我正在开发一款多人游戏,我的比赛已成功开始。在我的情况下,我有 3 名球员。播放器1,播放器2,播放器3。 从 Player3,我调用 GKMatch 对象的断开方法,我的断开方法是
-(void)disocnnectOnlineMatch {
[self.currOnlineMatch disconnect];
self.currOnlineMatch.delegate = nil;
self.currOnlineMatch = nil;
}
在 Player1 和 Player2 设备上,第一次调用此 didChangeState 函数,然后在一段时间后再次为 Player3 再次调用它。预计只调用一次,但双方玩家都调用2次
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
}
我在做什么? 断开匹配的最佳做法是什么?
有时也会发生这种情况,但会在一定延迟后调用 didChangeState 方法。虽然在游戏中需要对断开连接的玩家进行一些更新。
延迟响应的原因是什么?
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match {
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
currOnlineMatch = match;
currOnlineMatch.delegate = self;
[PuzzleLogicManager sharedManager].onlineNextRound = 2;
[self setupRandomNumberToSend:2.0f];
[presentingViewController dismissViewControllerAnimated:YES completion:^() {
//NSLog(@"dismissed");
}];
}
请帮忙
提前致谢
【问题讨论】: