我正在尝试使用 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];
}
}];
我按预期看到“分数已提交”,它会调出 Game Center 排行榜 View ,但它只是显示“无分数”
我知道其他人说过you need at least two accounts ,但我已经尝试了三个。
对于每个帐户,游戏会在 Game Center 应用程序中为他们显示,当我查询前十名时:
- (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);
}
}];
}
}
每个用户只能看到自己的分数。
那么为什么排行榜是空的,为什么每个用户只能看到自己的分数?
最佳答案
沙盒有时会很乱,但让我问你这个。你的 self.game.scoreMeter.score
是一个整数吗?
如果是这样,请尝试这样做:
myScoreValue.value = [[NSNumber numberWithInt:self.game.scoreMeter.score] longLongValue];
用于设置 GKScore 对象的值。如果它有任何变化,请告诉我。
关于iphone - Gamer Center 排行榜不显示分数,每个用户只能访问自己的分数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11681350/