1

我在我的 iPhone 游戏中使用 Game Kit,当我完成一个关卡时,我会检查这样的成就:

if (timeSpentInLevel < 30) {
        GKAchievement *ach = [[GKAchievement alloc] initWithIdentifier:@"cryptoquips.achievements.solutiontime.30s"];
        ach.percentComplete = 100.0;
        ach.showsCompletionBanner = YES;
        if (ach != NULL) {
            [ach reportAchievementWithCompletionHandler:^(NSError *error) {
                if (error!= nil) {
                    NSLog(@"achievement reporting failed");
                }
            }];
        }
    }

但是当我在另一个级别再次执行此操作时,无论如何都会显示横幅,并且我认为会再次获得积分。在 iTunes Connect 中,我将成就“Achievable More than Once”设置为 no,因此不允许这样做。

如何防止此成就被多次授予?

4

1 回答 1

1

您可以使用loadAchievementsWithCompletionHandler:来执行此操作。它将获得玩家已经获得的成就的 NSArray。枚举这个数组,看看有没有一个是你要解锁的成就,如果没有,就解锁。

于 2012-09-11T02:20:31.057 回答