How to check if the player is logged in Google Play Games?

0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I've integrated Google Play Game Services in my game. I've put a login button and leaderboard & achievement buttons. I've coded it so that only when CocoonJS -> On Login Succeeded then leaderboard and achievement buttons are enabled. The problem is that suppose a player logs into Google Play Game Services, now leaderboard and achievement buttons are enabled. Now he quits the game and re-opens it. He is already logged into the game (Welcome XYZ appears at the time of ludei splashscreen), but inside the game, the leaderboard and achievement buttons are disabled because It could not detect that player is already logged in. So, the player has to click the LOGIN button. Then, the other buttons are unlocked.

    I tried to do this:

    On start of layout: CocoonJS -> On Login Succeeded: Set global variable "loggedIn" to 1. If loggedIn is 1 then enable leaderboard and achievement buttons.

    But it is not working. Any help?

    Thanks

  • It is a shame they don't have this condition added already. I don't even know any javascript and I was able to fix the problem. You'll need to modify the cocoonjs 'edittime.js' and 'runtime.js' files. I looked at putting it on the ludei/cocoonjs github page but I can't figure the damn thing out and have no patience for it...

    I will post some screenshots of what you gotta do. It's not much. Just keep in mind that if you ever install an updated version of C2 or cocoonjs plugin, you will have to add the lines again or you could have issues. And make sure to back up the original edittime.js and runtime.js files before you tinker.

  • Just a reminder: since you are going to be editing some javascript files here, if you ever update C2 or the CocoonJS plugin, you will have to make these same edits again (or end up suffering from issues/bugs).

    Step 1: Navigate to the cocoonjs plugin folder (should be at --> C:\Program Files\Construct 2\exporters\html5\plugins\cocoonjsads)

    Step 2: Make backup copies of both edittime.js and runtime.js.

    Step 3: Open edittime.js and runtime.js (I use dreamweaver, but you can also use notepad).

    Step 4: Follow the pictures below (the lines of code are in bold below the pics for an easy copy/paste).

    [attachment=2:37xwugfw][/attachment:37xwugfw]

    AddCondition(31, 0, "Is Signed In", "Social", "Is Signed In", "True if the user is currently logged into the Google Play.", "isSignedIn");

    [attachment=1:37xwugfw][/attachment:37xwugfw]

    this.isSignedIn = false;

    Cnds.prototype.isSignedIn = function ()

    {

    if (this.socialServiceInterface.isLoggedIn())

    return true;

    else

    return false;

    };

    self.runtime.trigger(cr.plugins_.CJSAds.prototype.cnds.isSignedIn, self);

    [attachment=0:37xwugfw][/attachment:37xwugfw]

    I hope this makes sense. You may have to make another copy of the 2 files onto your desktop and edit the files from there (in my case I cannot make edits directly from the cocoonjsads folder).

  • Hey ! I saw that you have a working Google play leaderboard exported using cocoonjs right ? I am facing problem with Leaderboard, it doesn't show up on my Apk. It only makes login, i can't submit or retrieve highscore. Any help will be appreciated. Ciao !

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I Got my problem Fixed ! it was something in the developer console

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)