integrating google play games

Post on 21-Jun-2015

1.682 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

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

Achievements & Leaderboards

Using Google Play Services

It is actually quite smooth

Setup

On the Developer Console

On the Developer Console

Next, next, next

On the Developer Console

On the Android Project

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

AndroidManifest

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

GameUtils

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

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

Signing In

{...beginUserInitiatedSignIn();...

}

@Overridepublic void onSignInSucceeded() {

...}

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

GamesClient

Achievements

On the Developer Console

New Achievement

On the Android Project

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

Unlock an Achievement

getGamesClient().unlockAchievement(achievementId);

Show the Achievements

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

Leaderboards

On the Developer Console

Configure the Leaderboard

On the Android Project

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

Submit a Score

getGamesClient().submitScore(leaderboardId, points);

Open a Leaderboard

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

Open All Leaderboards

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

Not so smooth

If you forget the game_id it will just crash

Testing the integration

The game needs to be signed for release

About “Game Features”

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

Questions?

Thanks!

top related