安卓游戏API:排行榜 - 获取特定玩家的分数? [英] Android Game API: Leaderboard - Get specific player score?

查看:291
本文介绍了安卓游戏API:排行榜 - 获取特定玩家的分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决

我有一个快速的问题,我无法找到一个具体的解决方案。 问题是,我使用GooglePlay API一个排行榜。 我想要做的就是真正得到了什么是玩家分数为个人和特殊的球员。

I have a quick question that I cant find a specific solution. The problem is that I have a Leaderboard using GooglePlay API. What I want to do is actually get what is the player score for an individual and specific player.

例如我要显示在我的活动(不LeaderboardActivity)上的绳子,他有得分的排行榜,还是把它放在我的游戏的左上角。

For example I want to display the score he has in the leaderboard on a String on my activity (not LeaderboardActivity), or put it on top left corner of my game.

我怎样才能做到这一点?

How can I do this?

谢谢!

推荐答案

不知道为什么downvotes .. 反正这里是我发现了解决这个问题的方法:

Dont know why the downvotes.. Anyways here is the way I found to solve this:

在你的活动:

if (isSignedIn()) {
    getGamesClient().loadPlayerCenteredScores(
        this,
        getResources().getString(R.string.leaderboard_id),
        LeaderboardVariant.TIME_SPAN_ALL_TIME,
        LeaderboardVariant.COLLECTION_SOCIAL,
        25,
        true
    );
}

然后在监听器:

then on the listener:

@Override
public void onLeaderboardScoresLoaded(int arg0, LeaderboardBuffer arg1, LeaderboardScoreBuffer arg2) {
    Iterator<LeaderboardScore> it = arg2.iterator();
    while(it.hasNext()) {
         LeaderboardScore temp = it.next();
         Log.d("debug", "player:" + temp.getScoreHolderDisplayName() + " id:" + temp.getScoreHolder().getPlayerId());
    }
}

这名球员是中锋得分,所以如果你把甚至导致玩家应该是在中间。您可以循环,并检查玩家的ID相符。

The player is the center score so if you bring even results the player should be in the middle. You can iterate and check if the player id matches.

干杯。

这篇关于安卓游戏API:排行榜 - 获取特定玩家的分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆