简体   繁体   中英

Get Friend's Information from Google Play Games Services Android

I have a game on Android where GPGS (Google Play Games Services) is integrated and I submit highScores to Leaderboard.

What I'm trying to do is getting Friend's highScore and Profile Image to Show on Game Scene if I get better score.

I searched a lot but couldn't find any solution.

Is it possible to do such thing ? How can I get friends info ?

thanks in Advance.

You'd have to make at least 2 calls. The first is a call to [loadConnectedPlayers]( https://developers.google.com/android/reference/com/google/android/gms/games/Players.html#loadConnectedPlayers(com.google.android.gms.common.api.GoogleApiClient , boolean)). This will return the list of players that are in the circle of the player and have played the game before. The second is call is to get the leaderboard data. Since (hopefully) there are 1000s of scores, you should call [loadPlayerCenteredScores]( https://developers.google.com/android/reference/com/google/android/gms/games/leaderboard/Leaderboards.html#loadPlayerCenteredScores(com.google.android.gms.common.api.GoogleApiClient , java.lang.String, int, int, int)) to get the scores around the current player. You can use [loadMoreScores]( https://developers.google.com/android/reference/com/google/android/gms/games/leaderboard/Leaderboards.html#loadMoreScores(com.google.android.gms.common.api.GoogleApiClient , com.google.android.gms.games.leaderboard.LeaderboardScoreBuffer, int, int)) to page up or down in the leaderboard data.

Once you have both sets of data, you can compare the connected players to the player from the leaderboard which is retrieved by calling getScoreHolder , and compare the player Ids.

No, there's no direct API to do that.

The Android API has a method loadPlayerCenteredScores that allows you to load similar player scores in the leaderboard, but that's not 100% what you want. There doesn't seem to be an implementation of that method in the Unity wrapper .

I suggest you fall back to the standard leaderboard UI which shows the player's ranking among Google+ friends by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM