Currently I am doing game that integrated with Google Game Play Service and I want to compression score between score and best of score, so I easy inform player that they are getting New High Score. But I don't how to getscore from google game service leaderboard, can anybody please guide me on how to do it?
I am able to display leaderboard but i can't find the way how to get score for user playing.
my code that showing leaderboard:
if (isSignedIn())
{
if(inScore<=50)
{
Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard_easy), inScore);
}
else
{
Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard_hard), inScore);
}
} else {
Log.d("not signed", "Not signed in");
}
I want to get score from user that are playing on their device, help me please.
This is how I'm fetching the score of the current player:
private void loadScoreOfLeaderBoard() {
Games.Leaderboards.loadCurrentPlayerLeaderboardScore(getApiClient(), getString(R.string.your_leaderboard_id), LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
@Override
public void onResult(final Leaderboards.LoadPlayerScoreResult scoreResult) {
if (isScoreResultValid(scoreResult)) {
// here you can get the score like this
mPoints = scoreResult.getScore().getRawScore();
}
}
});
}
private boolean isScoreResultValid(final Leaderboards.LoadPlayerScoreResult scoreResult) {
return scoreResult != null && GamesStatusCodes.STATUS_OK == scoreResult.getStatus().getStatusCode() && scoreResult.getScore() != null;
}