I read all documentation about leaderboards in Google Play Services and it seems that when I call the submitScore function of GameClient the service take account of the highest score submitted only. E.g.:
1st call:
gamesclient.submitScore( 100 );
Now player score is 100
2nd call:
gamesclient.submitScore( 150 );
Now player score is 150
3rd call:
gamesclient.submitScore( 100 );
player score still remains 150. Submitted value isn't greater than last so it is ignored.
Is there a simple way to retrieve last player score, sum the new score and submit the total for create an incremental score leaderboard ? Something like
int old_score = ...GET LAST PLAYER SCORE...
int new_score = old_score + current_game_score;
gamesclient.submitScore( new_score );
Didn't test it so far, but i think thats the way to go:
PendingResult<Leaderboards.LoadPlayerScoreResult> result = Games.Leaderboards.loadCurrentPlayerLeaderboardScore(gameHelper.getApiClient(),"LEADERBOARD_ID",LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC);
result.setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {
@Override
public void onResult(Leaderboards.LoadPlayerScoreResult loadPlayerScoreResult) {
Games.Leaderboards.submitScore(gameHelper.getApiClient(), "LEADERBOARD_ID",loadPlayerScoreResult.getScore().getRawScore()+ score);
}
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