2014-02-18 102 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