Search code examples
objective-cios4game-center

GKAchievement (Game Center) showing?


this is a likely silly question. But I added Game Center to my app and now I want to add achievements, too. So I created a test achievement on itunesconnect and copied this method:

    - (void) reportAchievementIdentifier: (NSString*) identifier percentComplete: (float) percent {
    GKAchievement *achievement = [[[GKAchievement alloc] initWithIdentifier: identifier] autorelease];
    if (achievement)
    {
  achievement.percentComplete = percent;
  [achievement reportAchievementWithCompletionHandler:^(NSError *error)
   {
    if (error != nil)
    {
     // Retain the achievement object and try again later (not shown).
    }
   }];
    } }

But what do I have to do now. Where do I have to write the code that says that the achievement is reached? Where do I have to write the code that says that the achievement is reached by doing this?


Solution

  • If you're asking how to present the achievement to the user (i.e. "Achievement Earned!"), it's entirely up to you. Your game must implement the visuals in whatever way fits in the best.

    If you just need a quick and easy achievement display, try this:

    http://typeoneerror.com/blog/post/game-center-achievement-notification