Search code examples
javaandroidopenfeintleaderboard

Get scores and player info from leaderboard


I want to be able to show a list of the top ten or so scores for the levels in my game. I looked and I found that openfeint had a callback method for this

Leaderboard.getScores(Leaderboard.GetScoresCB cb)

I was not sure how to implement this so I tried

 public static void getScores(){
     Leaderboard l = new Leaderboard(getRightLB(level, section));
     float score = l.getScores(Leaderboard.GetScoresCB cb)
 }

I got a misplaced constructs error on the second line of the method. Implementation for the android version of feint seems pretty poor, does anyone know the correct way to implement this.

Also is it possible to also get user names and profile pics along with the score data?


Solution

  • Answer

    Set it up just like you were submitting a score, Duh!

    public static void getScores(){
         Leaderboard l = new Leaderboard("KEY");
         l.getScores(new Leaderboard.GetScoresCB() {
    
            @Override
            public void onSuccess(List<Score> scorelist) {
                // TODO Auto-generated method stub
    
            }
        });
     }
    

    EDIT: I've worked out the user name/profile picture thing.

    Turns out that the Score object comes bundled with other information as well as just the numerical value of the score.

    To get the numerical score value:

    scorelist.get(i).score;
    

    The corresponding username:

    scorelist.get(i).user.name;
    

    And the url of the profile picture:

    scorelist.get(i).user.profilePictureUrl;