我实现了gameKit,现在有一个问题: 游戏中心没有显示我的成就进度,所以玩家无法获得它们。 我的成就只有一个正常,我不知道为什么。
更新 如果我只使用一个if语句(那么我只有1个成就),它完美地工作......所以它必须用我的 if-conditions < / p>
-(void)updateAchievements{
NSString *achievementIdentifier;
float progressPercentage = 0.0;
BOOL progressInLevelAchievement = NO;
GKAchievement *levelAchievement = nil;
GKAchievement *scoreAchievement = nil;
if (progressInLevelAchievement) {
levelAchievement = [[GKAchievement alloc] initWithIdentifier:achievementIdentifier];
levelAchievement.percentComplete = progressPercentage;
}
if (score <= 11) {
progressPercentage = score * 100 / 11;
achievementIdentifier = @"Achievement_11Points";
}
if (score <= 22) {
progressPercentage = score * 100 / 22;
achievementIdentifier = @"Achievement_22Points";
}
if (score <= 55) {
progressPercentage = score * 100 / 55;
achievementIdentifier = @"Achievement_55Points";
//only the following achievement works
if ([Score addScore] <= 1000) {
progressPercentage = [Score addScore] * 100 / 1000;
achievementIdentifier = @"Achievement_1000Total";
}
scoreAchievement = [[GKAchievement alloc] initWithIdentifier:achievementIdentifier];
scoreAchievement.percentComplete = progressPercentage;
NSArray *achievements = (progressInLevelAchievement) ? @[levelAchievement, scoreAchievement] : @[scoreAchievement];
[GKAchievement reportAchievements:achievements withCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"%@", [error localizedDescription]);
}
}];
}
如果你可以帮助我会很棒:) ...非常感谢