我正在尝试在我的游戏和游戏中心做一个排行榜。我这样贴出高分:
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);
}
}];
}
}每个用户只能看到自己的分数。
那么,为什么排行榜是空的,为什么每个用户只看到自己的分数?
发布于 2012-08-02 12:09:46
好吧,事实证明你需要使用开发者沙盒帐户登录到游戏中心才能正常工作
发布于 2012-07-29 05:28:40
沙箱有时会很乱,但让我问你这个问题。你的self.game.scoreMeter.score是整型的吗?
如果是这样的话,尝试这样做:
myScoreValue.value = [[NSNumber numberWithInt:self.game.scoreMeter.score] longLongValue];用于设置GKScore对象的值。如果有什么改变,请告诉我。
https://stackoverflow.com/questions/11681350
复制相似问题