Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update (increment/decrement) leaderboard score in Google Play Games

I used the following code to submit the user's score to Google Play Games:

if(getApiClient().isConnected()){
            Games.Leaderboards.submitScore(getApiClient(), getString(R.string.number_guesses_leaderboard),newScore);
}

but this doesn't increment the score of leaderboard, it just replaces the score. The same value is shown the all the time. newScore is the amount that I want to increment the current score by.

like image 802
Sajitha Liyanage Avatar asked Apr 16 '17 06:04

Sajitha Liyanage


People also ask

How do I reset the leaderboard on Google Play?

Reset a leaderboard To reset leaderboards in the Google Play Console, click Reset progress at the top of the form for that event. To reset leaderboard data programmatically, call the Management API Scores methods.

How does leaderboard work?

Score by placement, 1st place receives 1 point; 2nd receives 2 points, etc. The overall competitors with the lowest point wins. Score by points, 1st place received 100 points, 2nd receives 95 points, etc. The overall competitors with the highest point wins.

What is a game leaderboard?

The term leaderboard is often used in the video gaming industry to signify rank among people who play various titles. Players can be ranked against other players based on their number of kills (most common), items collected, or some other metric.


1 Answers

You will need to save the current score locally using SharedPreferences, for example, and then submit the new total score to the Google Play Games service. Have a look a this sample by the Google Play Games team, specifically their use of an AccomplishmentsOutbox where they are storing the score locally until it is transmitted to the API.

like image 62
Miraduro Avatar answered Oct 13 '22 01:10

Miraduro