【问题标题】:Android Game API: Leaderboard - Get specific player score? [closed]Android 游戏 API:排行榜 - 获取特定玩家得分? [关闭]
【发布时间】:2013-08-09 13:14:04
【问题描述】:

已解决

我有一个快速的问题,我找不到具体的解决方案。 问题是我有一个使用 GooglePlay API 的排行榜。 我想要做的实际上是获取个人和特定玩家的玩家得分。

例如,我想在我的活动(不是 LeaderboardActivity)的字符串上显示他在排行榜中的得分,或者将它放在我游戏的左上角。

我该怎么做?

谢谢!

【问题讨论】:

  • 非常好的问题。赞成它

标签: java android google-api google-play-services leaderboard


【解决方案1】:

不知道为什么投反对票.. 无论如何,这是我找到解决此问题的方法:

关于你的活动:

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

然后在监听器上:

@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 是否匹配。

干杯。

【讨论】:

  • 实现哪个类来覆盖 onLeaderboardScoresLoaded 方法?你能帮帮我吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-04
  • 2014-06-08
  • 1970-01-01
  • 2018-02-09
  • 2019-03-22
  • 2012-03-11
  • 1970-01-01
相关资源
最近更新 更多