Game Development Reference
In-Depth Information
{
totalTime = 0.0f;
NSString* playedTenSeconds = @"PlayedForTenSecs";
GameKitHelper* gkHelper = [GameKitHelper sharedGameKitHelper];
GKAchievement* achievement = ←
[gkHelper getAchievementByID:playedTenSeconds];
if (achievement.completed == NO)
{
float percent = achievement.percentComplete + 10;
[gkHelper reportAchievementWithID:playedTenSeconds
percentComplete:percent];
}
}
...
}
Every time a second has passed, the achievement with the identifier
PlayedForTenSecs is obtained through GameKitHelper . If the achievement
isn't completed yet, then its percentComplete property is increased by 10 percent,
and the progress is reported through GameKitHelper 's reportAchieve-
mentWithID method ( Listing 14-15 ) .
Listing 14-15 . Reporting Achievement Progress
-(void) reportAchievementWithID:(NSString*)identifier percentComplete:(float)percent
{
if (isGameCenterAvailable == NO)
return;
GKAchievement* achievement = [self getAchievementByID:identifier];
if (achievement != nil && achievement.percentComplete < percent)
{
achievement.percentComplete = percent;
[achievement reportAchievementWithCompletionHandler:←
^(NSError* error)
{
 
 
Search Nedrilad ::




Custom Search