Latest commit 835c421
Apr 30, 2013
Added 2 methods to query number of total and completed achievements.
|Failed to load latest commit information.|
A simpler GameKitHelper inspired by Steffen Itterheim's version (http://www.learn-cocos2d.com). This version takes a different approach by synchronizing a local cache with game center and visa versa. I was having a lot of troubles getting Steffen's library to work nicely on iOS 4.2 devices. For one it was trying to write to the root bundle directory. I've switch it to write to /Library. I was also having trouble with achievements not always getting reported successfully. I think this has to do with Game Center not being consistent with callback errors on 4.x devices. Now everything is kept cached locally and each time game center comes back online it synchs both ways. So if an achievement is reported on game center but not locally, we re-cache it. If it's local but not in game center, we report it. This allows a fresh install of the app to automatically get all achievements and scores the first time it starts up. Steffen's GameKitHelper also did not cache scores. DDGameKitHelper keeps track of the high score in each category. So even though it reports the score each time (so that daily and weekly comparisons work), it's only cached locally if the high score has been beat. It also displays a message banner. DDGameKitHelper only deals with achievements and scores. Since none of my games use multiplayer I didn't try to tackle an api for that. I also have not tackled someone else signing in to game center. Right now I think everything locally would synch with the new account, which really isn't what you want neccessarily. So I will be working on a cache per user. (UPDATE: I've implemented this) The DDGameKitHelperDelegate class is dependent on Benjamin Borowski's GKAchievementNotification class. https://github.com/typeoneerror/GKAchievementNotification It does an excellent job of display a slide down notification that fits in seamlessly with game center. The only thing I needed to add to it was an adjustFrame method to compensate for the iPad. USING IT Authenticating a player ----------------------- [[DDGameKitHelper sharedGameKitHelper] authenticateLocalPlayer]; Checking authentication ----------------------- [[DDGameKitHelper sharedGameKitHelper] isLocalPlayerAuthenticated]; Unlocking an achievement ------------------------ [[DDGameKitHelper sharedGameKitHelper] reportAchievement:@"1" percentComplete:100]; Reporting a score ----------------- [[DDGameKitHelper sharedGameKitHelper] submitScore:newscore category:@"1"]; Showing achievements -------------------- [[DDGameKitHelper sharedGameKitHelper] showAchievements]; Showing scores -------------- [[DDGameKitHelper sharedGameKitHelper] showLeaderboard]; [[DDGameKitHelper sharedGameKitHelper] showLeaderboardwithCategory:@"LeaderboardID" timeScope:GKLeaderboardTimeScopeAllTime]; where GKLeaderboardTimeScopeAllTime is also available in GKLeaderboardTimeScopeToday and GKLeaderboardTimeScopeWeek Resetting achievements ---------------------- [[DDGameKitHelper sharedGameKitHelper] resetAchievements]; SUMMARY I know all of this functionality is available in iOS 5.x, but I want to still support my 4.x users. This library plays nicely with iOS 4.x and 5.x. Doug Davies Owner, Funky Visions www.funkyvisions.com