Giter Club home page Giter Club logo

rae / ddgamekithelper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from th-in-gs/ddgamekithelper

0.0 3.0 0.0 123 KB

A simpler GameKitHelper inspired by Steffen Itterheim's version. This version takes a different approach by synchronizing a local cache with game center and visa versa. It uses Benjamin Borowski's GKAchievementNotification class to display achievements and highscore banners.

Home Page: www.funkyvisions.com

License: MIT License

Objective-C 100.00%

ddgamekithelper's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.