Search code examples
cordovacordova-pluginsgoogle-play-gamesphaser-framework

cordova playGamesServices Get user score from leaderboard


I have used the below cordova plugin to connect to Google Play Games Services. https://github.com/artberri/cordova-plugin-play-games-services

Every thing is working fine. But in the documentation its not mentioned, how to get the user score from leaderboard. I am using Phaser as my game engine.


Solution

  • Looking at the source code, you can find the various actions listed in the execute function.

    It appears that there's an executeGetPlayerScore function you can use.

    The fork by alejandro-lopez seems to have received recent updates, so it may be a fork you'd want to submit a pull request to to include this in the documentation, since issues are turned off.

    From the asker, example code:

    window.plugins.playGamesServices.getPlayerScore(
        {leaderboardId: 'someID'},
        function(data) {
            // do something with data.PlayerScore;
        },function(e) {
            alert(JSON.stringify(e)); 
        }
    );