Jump to content

Google play services integration with phaser


Kapil
 Share

Recommended Posts

Hi..

 

i want to integrate my phaser with google play services to enable leaderboard. I have generated the client id successfully.

i have also included the following lines in my index.html :

 

<meta name="google-signin-clientid" content="xxxxxxxxxxxxxx.apps.googleusercontent.com" />
<meta name="google-signin-cookiepolicy" content="single_host_origin" />
<meta name="google-signin-callback" content="signinCallback" />
<meta name="google-signin-scope" content="https://www.googleapis.com/auth/games" />

<script src="https://apis.google.com/js/client.js"></script>

 

and then in Mainmenu state.....I am adding a button and in its handler  writing gapi.auth.signin().  but no signn in popup appears ..?

 

where am i going wrong?

 

I want to know whether it is advisable to use google play services in phaser games or not?

 

Actually I have hosted my game on google drive.  www.googledrive.com/host/0B_w6dYmu8MClflFIeGRxQ0tCRU55VXhDY05lQXJtVnJpaC1GREMxbzlDVGlfbnZScFpaZE0

 

not on a custom domain... Is this causing the problem ?

Link to comment
Share on other sites

I have only used google play services with phaser in my cocoonjs or cordova/phonegap games. I haven't tried web. Is it possible? do they show any working examples I can see so I can look at the source? 

Link to comment
Share on other sites

And nothing shows up in browser console? No errors, etc? In my browser I have problem with parsing js/index.js:

"Refused to execute script from <url> because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."

 

PS. To clarify for others play services are avail. for all devices. Only not all features are supported on every platform. You can read more at: https://developers.google.com/games/services/

Link to comment
Share on other sites

  • 1 month later...

I tried to use GPGS and it is good service. You can use for web game as well as for mobile game. Just read the docs properly. There is a REST interface for web.

When your user access your game/app, he/she must be signed in to Google+ service i.e you must use G+ "sign in" button or sign the user anonomously if the user already granted access and right to his personal G+ account.

 

Docs: https://developers.google.com/games/services/

https://developers.google.com/games/services/console/enabling

https://developers.google.com/apis-explorer/#p/

https://developers.google.com/games/services/web/gettingstarted

 

You must first create a client application ID for your app/game in your Google Developer Console. Add linked apps aka websites or mobile games to it and achievements. There should be at least 5 achievements and one linked live url for your game.

 

In order your game service to work you must publish it publicly so the achievements, leaderboards be available for use.

 

You can also use Firebug console to debug how the service works :)

 

Google services are very large thing so it is complex for not so experienced :) I was too confused when started coding some code in it.

 

You can also make a use of GPGS for multiplayer game :D

Link to comment
Share on other sites

Here is some code for the sign in button:

<script>        signinCallback = function(authResult) {            if (authResult['status']['signed_in']) {                document.getElementById('signinButton').setAttribute('style', 'display: none');                gapi.client.load('games', 'v1', function(response) {                    var request = gapi.client.games.leaderboards.list(                        {maxResults: 5}                    );                    request.execute(function(response) {                        // show table with available leaderboards                    });                });                            } else {                console.log('Sign-in state: ' + authResult['error']);            }        };    </script>

Each request to the service has two steps, first set up what you want to do and then execute that command. As in the code above

request = gapi.client.load() loads all available leaderboards and then request calls execute() function with function parameter what to do with the response from the server. So in this case you could display a grid or a table containing all available leaderboards for your game.

 

Analyze the DOM of gapi.client.games a bit in Firebug. There are lot of stuff about achievements, scores etc... and how to get data.

Link to comment
Share on other sites

I made a memory game so I thought a score board and achievements is not necessary since memory games aren't really popular. :D

 

I started something but stopped because of the reason mentioned.

 

But I will revisit that part and let you know. Will try to write a short tutorial how I did some stuff.

Link to comment
Share on other sites

I made something quick: http://gpgstest-spinnerbox.rhcloud.com/

It is only a score board for an imaginary game. Login with your G+ account by pressing signin button and then enter some value from 0 to 100000. If the select box doesn't refresh, refresh the page.

 

I will need some more time to add better functionality and also achievements...

 

But i would like this tested first. :)

 

This has useful info about accessin service data: https://developers.google.com/games/services/web/gettingstarted#communicating_with_services

Link to comment
Share on other sites

I was wondering, do you see only your own score in the list or you see a complete list of all who submited score?

 

Maybe I see daily :)

 

"Daily leaderboards reset at midnight PST every day, and weekly leaderboards reset at Saturday midnight PST."

 

https://developers.google.com/games/services/common/concepts/leaderboards

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...