Game Development Reference
In-Depth Information
[self setLastError:error];
if ([delegate respondsToSelector:@selector(onAchievementReported:)])
{
[delegate onAchievementReported:achievement];
}
}];
}
}
To avoid unnecessary calls to the Game Center server, the achievement's percent-
Complete property is verified to actually be smaller than the percent parameter.
Game Center doesn't allow achievement progress to be reduced and thus will ignore
such a report. But if you can avoid actually reporting this to the Game Center server in
the first place, you avoid an unnecessary data transfer. With the limited bandwidth
available on mobile devices, every bit of data not transmitted is a good thing.
Tip Reporting an achievement's progress may fail for a number of reas-
ons—for example, the device might have lost its Internet connection. Be pre-
pared to save any achievements that couldn't be transmitted. Then retry submit-
ting them periodically or when the player logs in the next time. The
KKGameKitHelper class provided with Kobold2D contains additional code
to cache achievements that failed transmission to the Game Center server.
This still leaves the question open: where do the achievements come from in the first
place? They're loaded as soon as the local player signs in. To make this possible, ex-
tend the block object used in authenticateWithCompletionHandler to call
the loadAchievements method if there wasn't an error:
[localPlayer authenticateWithCompletionHandler:←
^(NSError* error)
{
[self setLastError:error];
if (error == nil)
{
[self loadAchievements];
Search Nedrilad ::




Custom Search