如何增加球员得分在谷歌Android播放服务排行榜? [英] How to increment player score in leaderboards on Android Google Play Service?
问题描述
我读到的所有文件排行榜在谷歌播放服务,并似乎当我打电话GameClient的submitScore功能的服务考虑只提交了最高分。例如:
1号电话:
gamesclient.submitScore(100);
现在球员得分100
第二个呼叫:
gamesclient.submitScore(150);
现在球员得分150
第三个呼叫:
gamesclient.submitScore(100);
球员得分仍然是150提交的值是不是比去年更大,因此被忽略。
时去取回最后的球员得分,总结了新的成绩,并提交了总计创建增量比分领先一个简单的方法?类似于
INT old_score = ...获得最后一名分数...
INT new_score = old_score + current_game_score;
gamesclient.submitScore(new_score);
没有测试,到目前为止,但我认为是要走的路:
PendingResult< Leaderboards.LoadPlayerScoreResult>结果= Games.Leaderboards.loadCurrentPlayerLeaderboardScore(gameHelper.getApiClient(),"LEADERBOARD_ID",LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC);
result.setResultCallback(新ResultCallback&其中; Leaderboards.LoadPlayerScoreResult>(){
@覆盖
公共无效onResult(Leaderboards.LoadPlayerScoreResult loadPlayerScoreResult){
Games.Leaderboards.submitScore(gameHelper.getApiClient(),LEADERBOARD_ID,loadPlayerScoreResult.getScore()getRawScore()+得分。);
}
I read all documentation about leaderboards in Google Play Services and it seems that when I call the submitScore function of GameClient the service take account of the highest score submitted only. E.g.:
1st call:
gamesclient.submitScore( 100 );
Now player score is 100
2nd call:
gamesclient.submitScore( 150 );
Now player score is 150
3rd call:
gamesclient.submitScore( 100 );
player score still remains 150. Submitted value isn't greater than last so it is ignored.
Is there a simple way to retrieve last player score, sum the new score and submit the total for create an incremental score leaderboard ? Something like
int old_score = ...GET LAST PLAYER SCORE...
int new_score = old_score + current_game_score;
gamesclient.submitScore( new_score );
Didn't test it so far, but i think thats the way to go:
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);
}
这篇关于如何增加球员得分在谷歌Android播放服务排行榜?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!