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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With