2012-07-27 52 views
1

我正在嘗試使用Game Center在我的遊戲中製作排行榜。我張貼的高分,像這樣:玩家中心排行榜不顯示分數,每個用戶只能訪問他們自己的分數

GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"grp.high_scores"] autorelease]; 
    myScoreValue.value = self.game.scoreMeter.score; 

    NSLog(@"Attemping to submit score: %@", myScoreValue); 

    [myScoreValue reportScoreWithCompletionHandler:^(NSError *error){ 
     if(error != nil){ 
      NSLog(@"Score Submission Failed"); 
     } else { 
      NSLog(@"Score Submitted"); 
      id appDelegate = [[UIApplication sharedApplication] delegate]; 
      [appDelegate displayLeaderBoard:nil]; 
     } 

    }]; 

我看到「分數已提交」的期待,和它帶來了遊戲中心排行榜的看法,但它只是寫着「無得分」

我知道其他人有說you need at least two accounts,但我已經嘗試了三個。

對於每個帳戶,遊戲顯示爲他們在遊戲中心應用程序,當我查詢的十大得分:

- (void) retrieveTopTenScores 
{ 
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init]; 
    if (leaderboardRequest != nil) 
    { 
     leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal; 
     leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime; 
     leaderboardRequest.range = NSMakeRange(1,10); 
     [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) { 
      if (error != nil) 
      { 
       NSLog(@"Error grabbing top ten: %@", error); 
      } 
      if (scores != nil) 
      { 
       NSLog(@"Top ten scores: %@", scores); 
      } 
     }]; 
    } 
} 

每個用戶只能看到自己的分數。

那麼爲什麼排行榜是空的,爲什麼每個用戶只看到自己的分數?

回答

-1

事實證明,您需要使用開發人員沙盒帳戶登錄遊戲中心才能正常工作

0

沙箱有時可能會變得凌亂,但讓我問你這個問題。你的self.game.scoreMeter.score是int嗎?

如果是的話,試試這樣做:

myScoreValue.value = [[NSNumber numberWithInt:self.game.scoreMeter.score] longLongValue]; 

用於設置GKScore對象的值。讓我知道它是否會改變任何事情。

相關問題