how to implement multiple(for different game levels) leaderboard in android libgdx game? -
i having 3 different game levels.so there 3 different high scores need posted leaderboard on google play services. dont understand this. did have created 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() calling method on game on @ each level , sending high score there.
but when call getleaderboardgpgs() show last level high score.
so dont know how can implement multiple leaderboard.
you should create multiple leaderboards , use different id's in code. this: (untested)
private static string leaderboard0_id = ""; private static string leaderboard1_id = ""; public void submitscoregpgs(int score, int level); { string id = ""; if(level == 0) id = leaderboard0_id; else if(level == 1) id = leaderboard1_id; games.leaderboards.submitscore(gamehelper.getapiclient(),id , score); } public void getleaderboardgpgs() { if (gamehelper.issignedin()) { string id = ""; if(level == 0) id = leaderboard0_id; else if(level == 1) id = leaderboard1_id; startactivityforresult(games.leaderboards.getleaderboardintent(gamehelper.getapiclient(), id), 100); } else if (!gamehelper.isconnecting()) { logingpgs(); } }
Comments
Post a Comment