我想增加和减少我的分数
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.submitScore(getString(R.string.leaderboard_id), score);
用这种方式让我只增加我的分数
获取以前的分数:
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 loadPlayerScoreResult) {
mPoints = loadPlayerScoreResult.getScore().getRawScore();
}
});
}
增加:
Games.Leaderboards.submitScore(gameHelper.getApiClient(), "LEADERBOARD_ID",loadPlayerScoreResult.getScore().getRawScore()+ score);
减少:
Games.Leaderboards.submitScore(gameHelper.getApiClient(), "LEADERBOARD_ID",loadPlayerScoreResult.getScore().getRawScore()- score);