2014-02-18 180 views
0

檢索本土球員排行榜掙扎下載和顯示本地玩家高性分數顯示在遊戲中心 - 當前代碼顯示0,儘管比分是215如何從遊戲中心

GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init]; 
    leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal; 
    leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime; 
    leaderboardRequest.range = NSMakeRange(1,1); 

    int64_t personalBest= (int64_t)(leaderboardRequest.localPlayerScore.value * 1000000); 

    CCLabelTTF *HighScoreLabel = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"%lld",personalBest] fontName:@"MyScriptFont" fontSize:50.0]; 
    HighScoreLabel.positionType = CCPositionTypeNormalized; 
    HighScoreLabel.position = ccp(0.65f, 0.7f); 
    [self addChild:HighScoreLabel]; 

回答

0

根據apple documentation你需要調用loadScoresWithCompletionHandler來檢索分數。所以在將範圍稱爲以下之後。

[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) { 
      if (error != nil) 
      { 
       // Handle the error. 
      } 
      if (scores != nil) 
      { 
       // Process the score information. 
      } 
      }]; 
+0

關鍵點我失蹤..是要說明哪個排行榜id doh! leaderboardRequest.category = @「XXXXXXXX」; – user1150531