在 Google Play 游戏中更新(增加/减少)排行榜分数

Saj*_*age 5 android google-play-services android-studio google-play-games

我使用以下代码将用户的分数提交给 Google Play 游戏:

if(getApiClient().isConnected()){
            Games.Leaderboards.submitScore(getApiClient(), getString(R.string.number_guesses_leaderboard),newScore);
}
Run Code Online (Sandbox Code Playgroud)

但这不会增加排行榜的分数,它只是替换分数。始终显示相同的值。newScore是我想要增加当前分数的数量。

Mir*_*uro 3

例如,您需要使用 来本地保存当前分数SharedPreferences,然后将新的分数提交到 Google Play 游戏服务。查看Google Play 游戏团队提供的AccomplishmentsOutbox示例,特别是他们在本地存储分数直至将其传输到 API 的位置的使用。