ios - 如何在 iOS Game Center TURN-BASED App 中排除输了的玩家

标签 ios game-center

我在 iOS 游戏中心创建了一款回合制游戏, 游戏运行良好,数据在玩家之间正确传递。

我想知道:

你怎么能排除一个先于另一个输了的玩家?

我在任何地方都找不到引用资料 我该怎么走?

提前致谢,抱歉我的英语不好

安杰洛

编辑:

好的,我试过了,成功了(被排除的玩家也可以查看比赛)

    //When current player is excluded

GKTurnBasedMatch *currentMatch = [[GCTurnBasedMatchHelper sharedInstance] currentMatch];
currentMatch.currentParticipant.matchOutcome == GKTurnBasedMatchOutcomeQuit




//FOR SEND TURN : 

    NSUInteger currentIndex = [currentMatch.participants indexOfObject:currentMatch.currentParticipant];

    GKTurnBasedParticipant *nextParticipant;

    NSUInteger nextIndex = (currentIndex + 1) % [currentMatch.participants count];

    nextParticipant = [currentMatch.participants objectAtIndex:nextIndex];

    for (int i = 0; i < [currentMatch.participants count]; i++) {

        nextParticipant = [currentMatch.participants objectAtIndex:((currentIndex + 1 + i) % [currentMatch.participants count ])];

        if (nextParticipant.matchOutcome != GKTurnBasedMatchOutcomeQuit) {
            ///prossimo giocatore che NON è stato escluso
            break;
        } else {
            /////Prossimo giocatore perché questo è stato escluso
        }
    }



 [currentMatch endTurnWithNextParticipant:nextParticipant matchData:data completionHandler:^(NSError *error) {

            […]

        }];

最佳答案

我不是 Game Center 专家,但根据内存,您的代码可以选择下一个回合的人。因此,您可以计算出谁将在下一回合进行比赛,并简单地跳过任何已经输掉的玩家。不过,您可能应该更新他们的游戏数据,以便他们可以玩到最后。

Ray Wenderlich 有几个关于 Game Center 回合制游戏的示例教程:Beginning turn-based gaming with iOS 5

没有要分享的示例代码 - 抱歉。

关于ios - 如何在 iOS Game Center TURN-BASED App 中排除输了的玩家,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11246706/

相关文章:

ios - 核心数据并发调试: False Positive

ios - 最新比赛数据游戏中心

iphone - GameCenter 功能崩溃应用程序 - 谁能帮忙解决?

ios - 应用卸载后删除游戏中心记录

iOS/swift : How to manage network versatility with Alamofire

ios - 按钮单击事件在 iOS 中被触发两次或更多次

android - 如何将 Flutter Date 转换为 TimeStamp?

android - iBeacon协议(protocol)如何监控20多个区域?

ios - 设置第三方服务器与 Game Center 交互

ios - 游戏中心沙箱-既不真正登录也不注销