Integrating Google Play Games

31
Achievements & Leaderboards Using Google Play Services

description

Step by step description on how to use Achievements and Leaderboards from Google Play Games in an Android game. This was a 15 minutes session for the Dutch Android User Group on "Play Services"

Transcript of Integrating Google Play Games

Page 1: Integrating Google Play Games

Achievements & Leaderboards

Using Google Play Services

Page 2: Integrating Google Play Games

It is actually quite smooth

Page 3: Integrating Google Play Games

Setup

Page 4: Integrating Google Play Games

On the Developer Console

Page 5: Integrating Google Play Games

On the Developer Console

Page 6: Integrating Google Play Games

Next, next, next

Page 7: Integrating Google Play Games

On the Developer Console

Page 8: Integrating Google Play Games

On the Android Project

● Add google_play_services_lib● Update the AndroidManifest● Use GameUtils● Interact with GameClient

Page 9: Integrating Google Play Games

AndroidManifest

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />

Page 10: Integrating Google Play Games

GameUtils

https://github.com/playgameservices/android-samples/tree/master/BasicSamples/libraries/BaseGameUtils/src/main

● GameBaseActivity● GameHelper <- It is over 1,000 lines of code

Page 11: Integrating Google Play Games

Signing In

{...beginUserInitiatedSignIn();...

}

@Overridepublic void onSignInSucceeded() {

...}

Page 12: Integrating Google Play Games

The GamesClient object is used to communicate with the Google Play service.

GamesClient

Page 13: Integrating Google Play Games

Achievements

Page 14: Integrating Google Play Games

On the Developer Console

Page 15: Integrating Google Play Games

New Achievement

Page 16: Integrating Google Play Games

On the Android Project

● Import the ids● Unlock an Achievement● Open the Achievement List

Page 17: Integrating Google Play Games

Unlock an Achievement

getGamesClient().unlockAchievement(achievementId);

Page 18: Integrating Google Play Games

Show the Achievements

startActivityForResult(getGamesClient().getAchievementsIntent(), REQUEST_ACHIEVEMENTS);

Page 19: Integrating Google Play Games
Page 20: Integrating Google Play Games

Leaderboards

Page 21: Integrating Google Play Games

On the Developer Console

Page 22: Integrating Google Play Games

Configure the Leaderboard

Page 23: Integrating Google Play Games

On the Android Project

● Import the ids● Submit a score● Open a leaderboard● Open the Leaderboards List

Page 24: Integrating Google Play Games

Submit a Score

getGamesClient().submitScore(leaderboardId, points);

Page 25: Integrating Google Play Games

Open a Leaderboard

startActivityForResult(getGamesClient().getLeaderboardIntent(id), REQUEST_LEADERBOARDS);

Page 26: Integrating Google Play Games

Open All Leaderboards

startActivityForResult(getGamesClient().getAllLeaderboardsIntent(), REQUEST_LEADERBOARDS);

Page 27: Integrating Google Play Games

Not so smooth

Page 28: Integrating Google Play Games

If you forget the game_id it will just crash

Page 29: Integrating Google Play Games

Testing the integration

The game needs to be signed for release

Page 30: Integrating Google Play Games

About “Game Features”

They only appear after “some users” have used the features

Page 31: Integrating Google Play Games

Questions?

Thanks!