Kapil Posted March 22, 2015 Share Posted March 22, 2015 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 More sharing options...
Gods Posted March 23, 2015 Share Posted March 23, 2015 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 More sharing options...
Maxime Posted March 23, 2015 Share Posted March 23, 2015 Don't think it's possible to do so.It's an Android service so not available on desktop browser IMHO. Link to comment Share on other sites More sharing options...
Odk Posted March 23, 2015 Share Posted March 23, 2015 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 More sharing options...
Maxime Posted March 23, 2015 Share Posted March 23, 2015 Ok didn't know that was available for every platform. Thanks Odk. Link to comment Share on other sites More sharing options...
spinnerbox Posted May 6, 2015 Share Posted May 6, 2015 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/enablinghttps://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 shohan4556 and totallybueno 2 Link to comment Share on other sites More sharing options...
spinnerbox Posted May 6, 2015 Share Posted May 6, 2015 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 aboverequest = 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. totallybueno 1 Link to comment Share on other sites More sharing options...
totallybueno Posted May 7, 2015 Share Posted May 7, 2015 Thanks spinnerbox Also, can you share a working project to check the code? I have to deal with this for my game and it´s driving me crazy Link to comment Share on other sites More sharing options...
spinnerbox Posted May 7, 2015 Share Posted May 7, 2015 I made a memory game so I thought a score board and achievements is not necessary since memory games aren't really popular. 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 More sharing options...
totallybueno Posted May 7, 2015 Share Posted May 7, 2015 Please, that would be awesome, well, fucking awesome Link to comment Share on other sites More sharing options...
Gods Posted May 8, 2015 Share Posted May 8, 2015 Is there any production games I can play to test it? I cant find any online working demos only source code/docs Link to comment Share on other sites More sharing options...
spinnerbox Posted May 8, 2015 Share Posted May 8, 2015 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 totallybueno 1 Link to comment Share on other sites More sharing options...
totallybueno Posted May 8, 2015 Share Posted May 8, 2015 Hi there, thaaaaanks! That´s all I need, I´ll check it later to use it with my games I don´t like too much the idea that you need a google account but well, more or less everyone has one Thanks mate. Link to comment Share on other sites More sharing options...
spinnerbox Posted May 10, 2015 Share Posted May 10, 2015 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 More sharing options...
totallybueno Posted May 10, 2015 Share Posted May 10, 2015 I can see the whole list. Link to comment Share on other sites More sharing options...
spinnerbox Posted May 10, 2015 Share Posted May 10, 2015 It even has events and quests, like daily quests or weekly quests https://github.com/playgameservices/management-tools Somebody already did a proper job by putting all things toghether in one demo application: Check the link again http://gpgstest-spinnerbox.rhcloud.com/ Link to comment Share on other sites More sharing options...
Recommended Posts