Question

I'm trying to make a leaderboard in my game with Game Center. I post the high score like so:

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];
        }

    }];

I see "Score Submitted" as expecting, and it brings up the Game Center leaderboard view, but it just reads "No Scores"

I know other people have said you need at least two accounts, but I've tried with three already.

For each account, the game shows up for them in the Game Center App, and when I query for the top ten scores:

- (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);
            }
        }];
    }
}

each user only sees their own score.

So why is the leaderboard empty, and why is each user only seeing their own score?

Was it helpful?

Solution 2

Well, it turns out you need to be signed in to game center with a developer sandbox account for it to work correctly

OTHER TIPS

Sandbox can be messy sometimes, but let me ask you this. Is your self.game.scoreMeter.score an int?

If so, try doing this:

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

for setting the value of the GKScore object. Let me know if it changes anything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top