2012-02-02 118 views
4

因此,我將分數發送給GC排行榜,我沒有收到任何錯誤,而且分數正常發送,但我仍然看不到排行榜中列出的分數!排行榜本身在Game Center中列出,沒有得分。iOS遊戲中心沙箱:排行榜顯示「沒有得分」

根據Google搜索和question on here這可以通過嘗試記錄多個帳戶的分數來解決。我現在已經在模擬器(iOS5)和我的iPhone上嘗試了三個不同的帳戶;提交評分時,他們都沒有顯示任何錯誤。

發送比分的代碼是在這裏:

- (void)reportScore:(NSString *)identifier score:(int)rawScore { 

    GKScore *score = [[[GKScore alloc] initWithCategory:identifier] autorelease]; 
    score.value = rawScore; 
    [scoresToReport addObject:score]; 
    [self save]; // Save here even though we save again in didEnterBackground, just in case of crash... 

    if (!gameCenterAvailable || !userAuthenticated) return; 
    [self sendScore:score]; 
} 

- (void)sendScore:(GKScore *)score { 
    [score reportScoreWithCompletionHandler:^(NSError *error) { 
     dispatch_async(dispatch_get_main_queue(), ^(void) 
         { 
          if (error == NULL) { 
           NSLog(@"Successfully sent score!"); 
           [scoresToReport removeObject:score];     
          } else { 
           NSLog(@"Score failed to send... will try again later. Reason: %@", error.localizedDescription);     
          } 
         }); 
    }]; 
} 

回答

10

它突然開始工作(不更改任何代碼,甚至是重新編譯)。我認爲排行榜需要一段時間纔會真正出現,對我來說大約需要18個小時。

在這段時間內提交的比分仍然會記錄下來,他們只是不會立即可見。

0

我從來沒有得到的分數添加到沙箱要麼,但這裏是我實現的代碼,它目前工作正常版本的應用程序商店:

GKScore * score = [[[GKScore alloc] initWithCategory:@"com.example.appname.scoreboardname"] autorelease]; 
score.value = [[NSUserDefaults standardUserDefaults] integerForKey:@"NEWSCORE"]; 
[score reportScoreWithCompletionHandler:^(NSError *error) { 
    dispatch_async(dispatch_get_main_queue(), ^(void) { 
     if (error == NULL) { 
      NSLog(@"Score Sent"); 
     } else { 
      NSLog(@"Score Failed"); 
     } 
    }); 
}]; 

只要確保你的GKScore.value的類型是int64_t

相關問題