Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Game Center - Android [Tier 1] [AGK 2.0.20]

Author
Message
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 2nd Sep 2016 21:53
I wanted to mess around with Game Center in the hopes of including it in a few of my apps... However, the following code crashes my app immediately. I am using AppGameKit 2.0.20 ... This occurs with an exported app installed on my device... Interestingly, the app at least loads when broadcasting and I can see that both GC exists and is logged in (with the Print statements) - however trying to view the leaderboard fails to load (I can see it trying though).



I don't see anything in the export options specific to Game Center, so am I missing something?

Thanks in advance...
Using AppGameKit V2 Tier 1
Dud
13
Years of Service
User Offline
Joined: 21st Oct 2011
Location:
Posted: 3rd Sep 2016 09:59
Isn't GameCenter an iOS only feature?
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 3rd Sep 2016 10:35 Edited at: 3rd Sep 2016 10:35
Quote: "Isn't GameCenter an iOS only feature?"


I don't believe so...

I think I may have sussed it, when adding the Game Services details on the dev console it generates an Application ID and an OAuth2 Client ID. The Application ID must be included when exporting from AGK. The exported app must also have the same package name as the one you have configured on Game Services, which means this cannot be tested via broadcasting. Not had a chance to actually try this, just been doing some googling... I'll give this a try tonight, see if I can make some progress...
Using AppGameKit V2 Tier 1
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 3rd Sep 2016 21:37 Edited at: 3rd Sep 2016 21:55
Have made some excellent progress... Can now sign in to Game Center, submit scores and view the leaderboard... Happy days!

Something for Paul though, if you logout of Game Center via the app, the GetGameCenterLoggedIn() command still returns '1'. If you then try to interact with Game Center (like trying to view a leaderboard) this causes the app to crash.

Also, is it possible for you to implement some kind of acknowledgement when submitting a score to a leaderboard? There doesn't appear to be a way of knowing if the submission was successful...
Using AppGameKit V2 Tier 1
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Sep 2016 14:35
Quote: "if you logout of Game Center via the app, the GetGameCenterLoggedIn() command still returns '1'. If you then try to interact with Game Center (like trying to view a leaderboard) this causes the app to crash"

Thanks for letting me know. I'll take a look and see what I can do
pinete
13
Years of Service
User Offline
Joined: 28th Jul 2011
Location:
Posted: 19th Sep 2016 18:21
Hi Funnell7,
could you please tell us a little in-depth how you did that? What steps we should follow?
can you point us in the right direction regarding the android developer dashboard to configure the achievements or so?
Thanks a lot!
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 22nd Sep 2016 14:13 Edited at: 22nd Sep 2016 14:17
Quote: "could you please tell us a little in-depth how you did that? What steps we should follow?"


Of course... It's actually very simple. You first need to create a Game Services Profile on the Google Play Developer Console under 'Game Services'.

This requires you to update relevant information about your game. For the most part, this is the same information you have already used in you app (App Name, Description, Category etc).

Once that is done you will need to link the Game Services Profile to the App. This is as simple as selecting the relevant app from the drop down. In doing so, an application ID will be generated which you will need to include when exporting the application from AGK.

You then have the ability to create Events, Achievements and Leaderboards. Events are not mandatory, but you must have at least 5 achievements before you can publish Game Services.

Events: These are things you wish to track within the game, lives lost, levels complete, that sort of thing. This helps you track engagement. I didn't use any of these.

Achievements: Self explanatory. Things a user can 'Achieve' in your game. These are unlocked by sending a percentage complete back to Game Center.

Leaderboards: Again, self explanatory. You have a few customisation options when it comes to the Leaderboards, things like how you want the score to display, whether it be a number, currency, time etc.

Once you have added your achievements and/or Leaderboards, Google Play generates a unique ID (resources) for each of these. You then use these ID's within your code to send information to Google Play.

AGK Set up:

I call the initial setup command almost immediately, prior to my declares.



I then call the login procedure (only once, not in a loop) whilst the titlescreen is being displayed. This prompts the user to login to Game Services (if not alreday logged in).



Viewing the leaderboard. Simply call the following command to view the leaderboard. You will need to include the leaderboard ID (resource) from Google Play.



Viewing achievements. Note, this one does not require a resource ID.



Notice that I invoke the Login procedure if the user is not already logged in. I do this, in case they failed to login initially.

Submitting leaderboard scores.



Submitting an achievement. Call the below command when the user has obtained the achievement. You can pass a % complete so the user can track their progress, or, do as we did and simply pass 100 once complete.



I included an internal check for achievement progress to prevent this command from being called multiple times, for example, we have an achievment in our game for when the user has a Bank Balance of over £100. This looks like this...



As mentioned above, when exporting the app from AppGameKit, be sure to include the Game Services ID on Google Play and you should be golden. Very simple to implement and in my opinion, really adds to the game. I'm in the process of adding Game Center/Services to all our games I haven't tried this on iOS, but I would imagine the process is almost identical...

Good luck

Oh one last thing, in terms of testing, you can do so by adding you Google email address to the testing tab. Anyone added here will be able to interact with you Game Services profile before publishing. You can also reset the leaderboards/achievement progress on non pulished profiles.

Do no test Game Services via broadcasting!! For some reason, this causes your device to lose access to the leaderboard once you have published. I assume its because the AppGameKit Player doesn't have the associated App ID?

Let me know if you have any further questions...
Using AppGameKit V2 Tier 1
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 22nd Sep 2016 17:12
Very informative! Thanks. In my game, I have a requirement for lives to gradually recover over time (I have achieved this through communication with my server - a little PHP / MySQL setup). It would be cool if I didn't need to use my own server and do it all through Game Services!

V2 T1 (Mostly)
Phone Tap!
Uzmadesign

Login to post a reply

Server time is: 2024-11-25 01:36:10
Your offset time is: 2024-11-25 01:36:10