Google Play排行榜服务

问题描述 投票:0回答:1

我想增加和减少我的分数

    Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this))
            .submitScore(getString(R.string.leaderboard_id), score); 

用这种方式让我只增加我的分数

android google-play-games leaderboard
1个回答
0
投票

获取以前的分数:

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);
© www.soinside.com 2019 - 2024. All rights reserved.