7

以下の関数を使用して、スコアをゲームセンターに送信しています。すでに送信されたスコアよりも高い場合にのみスコアを送信できるように、以下のコードを変更するにはどうすればよいですか?そして、私はスコアをローカルに維持したくありません。何か助けはありますか?

- (void) reportScore: (int64_t) score forCategory: (NSString*) category 
{
 GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease]; 
 scoreReporter.value = score;
 [scoreReporter reportScoreWithCompletionHandler: ^(NSError *error) 
  {
   [self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
  }];
}

ありがとう。

編集:ゲームセンターでのみ処理されていることがわかりました...ゲームセンターアプリにはトップスコアのみが表示されます。

4

1 に答える 1

3

を使用して以前のスコアを取得できます

GKLeaderboard *query = [[GKLeaderBoard alloc] initWithPlayerIDs:[NSArray arrayWithObject:yourPlayerId]];

if (query != nil)

{

    [query loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {

        if (error != nil)

            // handle the error.

        if (scores != nil)

            // process the score information.

        }];

}

AppleGameKitプログラミングガイドの詳細情報を入手する

于 2010-10-06T13:32:18.323 に答える