Reputation: 3818
I have an 'endless' game, where the user has to get as high a score as possible. I have made some achievements, for when they reach 30, 60, 90 points, etc. However, when the user reaches those scores, no banner is shown to say that they have completed the achievement, nor is it shown as completed in Game Center.
How do I do this?
This is my code:
func checkAchievements() {
var identifier : String? = nil
var percentComplete : Double = 0
switch(score)
{
case 30:
identifier = "30"
percentComplete = 100.0
case 60:
identifier = "60"
percentComplete = 100.0
case 90:
identifier = "90"
percentComplete = 100.0
case 120:
identifier = "120"
percentComplete = 100.0
case 150:
identifier = "150"
percentComplete = 100.0
default:
identifier = nil
}
if identifier != nil {
let achievement = GKAchievement(identifier: identifier)
achievement.showsCompletionBanner = true
achievement.percentComplete = percentComplete
}
}
Upvotes: 1
Views: 1816
Reputation: 3440
I have never used the GK module but while you have instantiated a GKAchievement object, I don't see your call to report/record it with Game Center. Where is achievement.reportAchievementWithCompletionHandler: ?
Upvotes: 4