我使用此代码从排行榜中获得最高分,但我不断获得
java.lang.IllegalStateException
在
LeaderboardScore lbs = arg0.getScores().get(0);
我不知道哪里出了问题。它在我之前的项目中有效
public void updateTops() {
Games.Leaderboards.loadTopScores(client, getString(R.string.leaderboard_score),
LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, 2, true).
setResultCallback(new ResultCallback<Leaderboards.LoadScoresResult>() {
@Override
public void onResult(final Leaderboards.LoadScoresResult arg0) {
System.out.println("SUKA " + score);
LeaderboardScore lbs = arg0.getScores().get(0);
score = lbs.getDisplayScore();
name = lbs.getScoreHolderDisplayName();
arg0.getScores().close();
}
});
}
最佳答案
这样试试:
Games.Leaderboards.loadTopScores(mGamesClint,LEADERBOARD_ID, LeaderboardVariant.TIME_SPAN_ALL_TIME, LeaderboardVariant.COLLECTION_PUBLIC, 5).setResultCallback(new ResultCallback<Leaderboards.LoadScoresResult>() {
public void onResult(LoadScoresResult arg0) {
if(arg0 != null) {
if (arg0.getStatus().getStatusCode() == GamesStatusCodes.STATUS_OK) {
int size = arg0.getScores().getCount();
LeaderboardScoreBuffer scoreBuffer = arg0.getScores();
Iterator<LeaderboardScore> it = scoreBuffer.iterator();
while(it.hasNext()){
LeaderboardScore temp = it.next();
Log.d("PlayGames", "player"+temp.getScoreHolderDisplayName()+" score:"+temp.getDisplayScore());
}
}
}
}
关于android - Libgdx 最高分。谷歌播放服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42320355/