Search code examples
androidlibgdxgoogle-play-services

how to implement multiple(for different game levels) leaderboard in android libgdx game?


I am having 3 different game levels.So there would be three different high scores that need to be posted for Leaderboard on google play services. I dont understand this. what I did is that I have created a method

 public void submitScoreGPGS(int score);
 {
      Games.Leaderboards.submitScore(gameHelper.getApiClient(),"id", score);
 }

 public void getLeaderboardGPGS() {             
      if (gameHelper.isSignedIn()) 
      {
          startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(), ""), 100);
      } 
      else if (!gameHelper.isConnecting()) 
      {
          loginGPGS();
      }
 }

For submitScore() I am simply calling this method on Game over at each level and sending High score from there.

But when I call getLeaderboardGPGS() it only show the last level high score.

So I dont know how can I implement this multiple leaderboard.


Solution

  • To send score to multiple leaderboard there is a need to create all those multiple leaderboard and just send score to particular one.

    To call all leaderboard at once on single button click use this

    on getleaderboard()

    startActivityForResult( Games.Leaderboards.getAllLeaderboardsIntent( gameHelper.getApiClient()), 1 ); 
    

    . Might help somebody.