我阅读了有关的所有文档排行榜 https://developers.google.com/games/services/common/concepts/leaderboards在Google Play服务中,当我调用GameClient的submitScore函数时,该服务似乎只考虑提交的最高分数。例如。:
第一次通话:
gamesclient.submitScore( 100 );
现在玩家得分为100
第二次通话:
gamesclient.submitScore( 150 );
现在玩家分数为150
第三次通话:
gamesclient.submitScore( 100 );
玩家得分仍为 150。提交的值不大于上次的值,因此会被忽略。
有没有一种简单的方法来检索最后一个玩家的得分,将新得分相加并提交总数以创建增量得分排行榜?就像是
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(), "LEADERBOARD_ID",loadPlayerScoreResult.getScore().getRawScore()+ score);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)