0

I am trying to display a leaderboard for my game using google play services. The game is html/js. I have an instance of gapi loaded. I submit a score in the following way:

var json={};
json.leaderboardId='dlsfhqo3irhq';
json.score=666;
gapi.client.games.scores.submit(json); 

I then try to display a leaderboard as follows:

var json={};
json.leaderboardId='dlsfhqo3irhq';
json.collection='PUBLIC';
json.timeSpan='ALL_TIME';
gapi.client.games.scores.listWindow(json);

Nothing appears. I have set up the leaderboard in the developer console which says it is ready for testing. Also I am displaying the leaderboard in response to a click so that no popups are blocked.

gloo
  • 2,490
  • 3
  • 22
  • 38

1 Answers1

0

All of the google (game) api's have two stages. First is to setup the request, then you need to execute.

Your code should look something like:

var json= { leaderboardId: 'dlsfhqo3irhq', collection: 'PUBLIC', timeSpan:'ALL_TIME'};
var request = gapi.client.games.scores.listWindow(json);
request.execute(function(response) { 
// do something
});
Gavin Mogan
  • 1,497
  • 1
  • 14
  • 21