1

私はiOSゲームセンターでゲームターンベースを作成しました。ゲームはうまく機能し、データはプレーヤーからプレーヤーに適切に渡されます。

知りたかった:

他のプレイヤーより先に負けたプレイヤーをどのように除外できますか?

どこにも参照が見つかりませんどうすればいいですか?

よろしくお願いします。英語でごめんなさい

アンジェロ

編集:

OK、これを試してみましたが、うまくいきました(除外されたプレイヤーも試合を見ることができます)

    //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) {

            […]

        }];
4

1 に答える 1

1

私はGameCenterの専門家ではありませんが、記憶から、あなたのコードは次のターンを誰が取るかを選択できます。したがって、次のターンに誰が参加するかを計算し、すでに負けたプレーヤーをスキップすることができます。ただし、ゲームを最後までフォローできるように、ゲームデータを更新する必要があります。

Ray Wenderlichには、GameCenterのターンベースのゲームに関するチュートリアルの例がいくつかあります。iOS5でターンベースのゲームを開始する

共有するサンプルコードはありません-申し訳ありません。

于 2012-06-28T22:39:36.043 に答える