Android Game API: Leaderboard - Get specific player score? [closed]
Asked Answered
C

1

8

SOLVED

I have a quick question that I cant find a specific solution. The problem is that I have a Leaderboard using GooglePlay API. What I want to do is actually get what is the player score for an individual and specific player.

For example I want to display the score he has in the leaderboard on a String on my activity (not LeaderboardActivity), or put it on top left corner of my game.

How can I do this?

Thanks!

Citrate answered 7/8, 2013 at 23:41 Comment(0)
C
8

Dont know why the downvotes.. Anyways here is the way I found to solve this:

On your activity:

if (isSignedIn()) {
    getGamesClient().loadPlayerCenteredScores(
        this,
        getResources().getString(R.string.leaderboard_id),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL,
        25,
        true
    );
}

then on the listener:

@Override
public void onLeaderboardScoresLoaded(int arg0, LeaderboardBuffer arg1, LeaderboardScoreBuffer arg2) {
    Iterator<LeaderboardScore> it = arg2.iterator();
    while(it.hasNext()) {
         LeaderboardScore temp = it.next();
         Log.d("debug", "player:" + temp.getScoreHolderDisplayName() + " id:" + temp.getScoreHolder().getPlayerId());
    }
}

The player is the center score so if you bring even results the player should be in the middle. You can iterate and check if the player id matches.

Cheers.

Citrate answered 8/8, 2013 at 0:52 Comment(1)
which class to implement to override onLeaderboardScoresLoaded method? Can you help me please?Sickening

© 2022 - 2024 — McMap. All rights reserved.