Hello,
I'm working on a simple game with gamecenter support, writing it in SWIFT. I've got a lot of gamecenter stuff working so far:
1) Authentication works!
2) Achievements work
3) Submitting high scores works
Where I'm running into problems, is retrieving the high scores. I've got 2 test users, who have both logged in and played the game, and submitted high scores.
When I call code to get a list of all the high scores, I'm only getting 1 high score back ... the score for the logged in user. I'm not seeing anything for the second user. I think this is because the 2 test users are not "friends" (I actually am not sure how to even make them friends).
From what I see on the doc, the problem is when I request the leaderboard, I have to set the playerScore to Global instead of FriendsOnly. But I am already doing that, and it doesn't seem to have any effect at all. Does anyone know if there's a trick to this? Here's the code:
I'm working on a simple game with gamecenter support, writing it in SWIFT. I've got a lot of gamecenter stuff working so far:
1) Authentication works!
2) Achievements work
3) Submitting high scores works
Where I'm running into problems, is retrieving the high scores. I've got 2 test users, who have both logged in and played the game, and submitted high scores.
When I call code to get a list of all the high scores, I'm only getting 1 high score back ... the score for the logged in user. I'm not seeing anything for the second user. I think this is because the 2 test users are not "friends" (I actually am not sure how to even make them friends).
From what I see on the doc, the problem is when I request the leaderboard, I have to set the playerScore to Global instead of FriendsOnly. But I am already doing that, and it doesn't seem to have any effect at all. Does anyone know if there's a trick to this? Here's the code:
Code:
let leaderBoardRequest = GKLeaderboard()
leaderBoardRequest.identifier = "main_leaderboard"
leaderBoardRequest.playerScope = GKLeaderboardPlayerScope.Global
leaderBoardRequest.timeScope = GKLeaderboardTimeScope.AllTime;
leaderBoardRequest.loadScoresWithCompletionHandler { (scores, error) -> Void in
if (error != nil) {
println("Error: \(error!.localizedDescription)")
} else if (scores != nil) {
let localPlayerScore = leaderBoardRequest.localPlayerScore
println("Local player's score: \(localPlayerScore.value)")
println("High score: \(leaderBoardRequest.scores.first)")
println("All scores: \(scores)")
}
}