Julien
Julien

Reputation: 1067

Libgdx game using Google Play Game Services on iOS and Android

I am creating a game using Libgdx and would like to integrate player, Leaderboard, high score on both iOS and Android devices. Ideally I would use Google Play Game Services but I could be convinced to use other technologies (like Parse).

There are tutorials to use Google Play services for Android devices: (http://theinvader360.blogspot.co.uk/2013/10/google-play-game-services-tutorial-example.html). But as far as I understand, this will not work for iOS devices (according to this:https://developers.google.com/games/services/integration/)

There are also tutorials to do so on iOS devices, using RoboVM: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=11424 but as far as I understand this will only work for iOS devices.

Since one of libgdx benefit is to write once but to run cross platforms, my Question is the following: How do I integrate with Google Play Game Services and run on iOS and Android.

It seems to me that the answer is to use the REST API (https://developers.google.com/games/services/web/api/) since this is technologically agnostic, but that means that I then need to implement quite a few things (login, notifications...)

I cannot imagine I am the first one to be facing this but it seems there are no examples available on the subject.

Upvotes: 2

Views: 1422

Answers (1)

noone
noone

Reputation: 19796

You don't have to use the REST API for this, even though that would certainly be an option.

The easier way is the use of platform specific code via interfacing.

Everything that is not directly integrated into libGDX won't work via "write once, run everywhere". This also applies to achievements, leaderboards and other things that Google Play Game Services offer. However, you are lucky that GPGS unites these features within one framework for at least Android, iOS and Web.

So what you would do, is adding the platform specific library dependencies to the platform specific projects you have generated. Then implement a generic interface, e. g. AchievementHandler with methods like unlockAchievement(String achievementId).

Then you would implement this interface via AndroidAchievementHandler that makes use of GPGS. The same will work with an IOSAchievementHandler.

In your core code, you will only use AchievementHandler and each platform will use its own implementation of this.

Upvotes: 3

Related Questions