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.
if GetGameCenterExists() = 1 // This checks to see if Game Center/Game Services exist on the device
GameCenterSetup()
endif
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).
if GetGameCenterLoggedIn() = 0
GameCenterLogin()
endif
Viewing the leaderboard. Simply call the following command to view the leaderboard. You will need to include the leaderboard ID (resource) from Google Play.
if GetGameCenterLoggedIn() = 1
GameCenterShowLeaderBoard("resourceID")
else
GameCenterLogin()
endif
Viewing achievements. Note, this one does not require a resource ID.
if GetGameCenterLoggedIn() = 1
GameCenterAchievementsShow()
else
GameCenterLogin()
endif
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.
if GetGameCenterLoggedIn() = 1
GameCenterSubmitScore(Score, "resourceID") // Score as integer
endif
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.
if GetGameCenterLoggedIn() = 1
GameCenterSubmitAchievement("resourceID", PercentageComplete) // PercentageComplete as integer
endif
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...
if GetGameCenterLoggedIn() = 1
if BankBalance >= 100.0 AND BankBalanceAch = 0
GameCenterSubmitAchievement("resourceID", 100)
BankBalancAch = 1 // I save this variable to a file which then prevents this command from being called multiple times.
endif
endif
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