0

Please tell me how to implement google play service leader board in andengine ?

Is there any tutorial ?

I searches all the questions on google regarding my question but did not find anything useful.

nilesh
  • 41
  • 1
  • 7

1 Answers1

1

There’s a few things you need to do here.

1) Import BaseGameUtils into your project. You can download it from here

2) Update your build.gradle file dependencies to include it

dependencies { .... compile project(':BaseGameUtils’) ....

3) Make sure you’ve updated your manifest correctly

<manifest xmlns:android="http://schemas.android.com/apk/res/android”
………

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

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

4) Modify the name of BaseGameActivity in BaseGameUtils to e.g. GMSBaseGameActivity and make it extend SimpleBaseGameActivity or BaseGameActivity (whichever you’re using). Then update your main activity to extend GMSBaseGameActivity (overriding onSignInFailed and onSignInSucceeded).

Now you’re app should automatically connect when it starts.

Use getGameHelper().isSignedIn() to query if the user is signed in.

Use startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getGameHelper().getApiClient(), getResources().getString(R.string.your_leaderboard_id)), 0); to display the leaderboard

Use Games.Leaderboards.submitScore(getGameHelper().getApiClient(), getResources().getString(R.string.your_leaderboard_id), this_is_the_score_submitted); to submit a score.

user01000101
  • 421
  • 4
  • 13