iOS 游戏中心沙盒环境:排行榜显示“无得分”

4
所以我正在向GC排行榜发送分数,我没有收到任何错误,并且分数似乎已经发送了,但是我仍然看不到排行榜中列出的分数!排行榜本身在Game Center中列出,只是没有分数。
根据谷歌搜索和这里的问题,这可以通过尝试使用多个帐户记录分数来解决。我现在已经在模拟器(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);                
                           }
                       });
    }];
}
2个回答

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类型


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接