【问题标题】:Google Play Leaderboard serviceGoogle Play 排行榜服务
【发布时间】:2019-02-21 02:45:41
【问题描述】:

我想增加和减少我的分数

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

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

【问题讨论】:

    标签: android google-play-games leaderboard


    【解决方案1】:

    获取以前的分数:

    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);
    

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 2014-12-19
      • 1970-01-01
      • 2018-02-07
      • 2016-08-09
      • 2013-05-12
      • 2018-01-05
      • 1970-01-01
      相关资源
      最近更新 更多