我在Google Play服务中阅读了有关
leaderboards的所有文档,似乎当我调用GameClient的submitscore函数时,服务仅考虑提交的最高分数.例如.:
第一个电话:
gamesclient.submitscore( 100 );
现在玩家得分是100
第二个电话:
gamesclient.submitscore( 150 );
现在玩家得分是150
第三个电话:
gamesclient.submitscore( 100 );
玩家得分仍然保持150.提交的值不大于last,所以它被忽略.
是否有一种简单的方式来检索最后的玩家得分,总结新的得分,并提交总计创建增量分数排行榜?就像是
int old_score = ...GET LAST PLAYER score... int new_score = old_score + current_game_score; gamesclient.submitscore( new_score );
解决方法
没有测试到目前为止,但我认为这样做的方式:
PendingResult<Leaderboards.LoadPlayerscoreResult> result = Games.Leaderboards.loadCurrentPlayerLeaderboardscore(gameHelper.getApiClient(),"LEADERBOARD_ID",LeaderboardVariant.TIME_SPAN_ALL_TIME,LeaderboardVariant.COLLECTION_PUBLIC); result.setResultCallback(new ResultCallback<Leaderboards.LoadPlayerscoreResult>() { @Override public void onResult(Leaderboards.LoadPlayerscoreResult loadPlayerscoreResult) { Games.Leaderboards.submitscore(gameHelper.getApiClient(),loadPlayerscoreResult.getscore().getRawscore()+ score); }