我设置了通过游戏第一级的成就,但是当我重放关卡并通过它再次显示通知横幅时,我该怎样才能防止这种情况发生?
答案 0 :(得分:11)
使用此方法提交成就:
-(void) reportAchievementWithID:(NSString*) achievementID {
[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error) {
if(error) NSLog(@"error reporting ach");
for (GKAchievement *ach in achievements) {
if([ach.identifier isEqualToString:achievementID]) { //already submitted
return ;
}
}
GKAchievement *achievementToSend = [[GKAchievement alloc] initWithIdentifier:achievementID];
achievementToSend.percentComplete = 100;
achievementToSend.showsCompletionBanner = YES;
[achievementToSend reportAchievementWithCompletionHandler:NULL];
}];
}
答案 1 :(得分:-2)
保存用户已将级别传递给NSUserDefaults
,然后当用户通过级别检查NSUserDefaults
获取密钥时,如果有,则不执行游戏中心的成就代码