2

这可能是一个愚蠢的问题。但我将 Game Center 添加到我的应用程序中,现在我也想添加成就。于是我在itunesconnect上创建了一个测试成就,复制了这个方法:

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

但是我现在该怎么办。我必须在哪里编写说明已达到成就的代码?我必须在哪里编写代码,说明通过这样做可以达到成就?

4

2 回答 2

5

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

于 2010-11-29T20:42:08.980 回答
1

使用 GKAchievement 实例属性showsCompletionBanner向用户显示系统成就横幅。

一个布尔值,用于说明成就完成时是否显示横幅。

斯威夫特 4

let achievement = GKAchievement(identifier: achievementId)
achievement.percentComplete = 100.0
achievement.showsCompletionBanner = true

对象

GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier: achievementId];
[achievement setPercentComplete:100.0];
[achievement setShowsCompletionBanner:YES];
于 2018-03-10T20:18:14.010 回答