Domanda

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.

È stato utile?

Soluzione

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
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top