gpt4 book ai didi

android - 如何从当前玩家的 google play 游戏服务排行榜中获取分数?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:59:55 27 4
gpt4 key购买 nike

目前我正在做与 Google Game Play 服务集成的游戏,我想在分数和最佳分数之间压缩分数,所以我很容易通知玩家他们获得了新的高分。但是我不知道如何从谷歌游戏服务排行榜上获得分数,有人可以指导我如何做吗?

我可以显示排行榜,但我找不到如何为用户游戏获取分数的方法。

我的显示排行榜的代码:

if (isSignedIn())
{
if(inScore<=50)
{
Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard_easy), inScore);
}
else
{
Games.Leaderboards.submitScore(getApiClient(), getString(R.string.leaderboard_hard), inScore);
}
} else {
Log.d("not signed", "Not signed in");
}

我想从在他们的设备上玩游戏的用户那里获得分数,请帮助我。

最佳答案

这就是我获取当前玩家分数的方式:

private void loadScoreOfLeaderBoard() {
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 scoreResult) {
if (isScoreResultValid(scoreResult)) {
// here you can get the score like this
mPoints = scoreResult.getScore().getRawScore();
}
}
});
}

private boolean isScoreResultValid(final Leaderboards.LoadPlayerScoreResult scoreResult) {
return scoreResult != null && GamesStatusCodes.STATUS_OK == scoreResult.getStatus().getStatusCode() && scoreResult.getScore() != null;
}

关于android - 如何从当前玩家的 google play 游戏服务排行榜中获取分数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23248157/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com