LibGDX and google-mobile-ads Robopods integration (iOS)

I just started porting my existing android game (word-hunter) to iOS and ran into a lot of troubles trying to make adMob works on iOS with libgdx and robovm, so I figure someone else might need this :)

You should probably already have an Interface in your libgdx core project to specify the actions correspond to the display of ads:

public interface AdsDisplayInterface{
   public void loadAd();
   public void showAd();

And your game constructor should expect an implementation of this interface as argument:

public class Game implements ApplicationListener {
   public AdsDisplayInterface _adsDisplay;

   public Game(AdsDisplayInterface adsDisplay){
      _adsDisplay = adsDisplay;

   public Game(){

      public void create() {

Now you can call _adsDisplay.loadAd() and _adsDisplay.showAd() anytime you want in your game, see this post for more details on how this works.

Now we want to create a class implementing this Interface in the platform where we want to display ads, in our case: iOS.

First we need to integrate the google-mobile-ads robopod binding (git repo).

Follow the instructions from the README in the git website and use either graddle or maven to add the binding.

I added compile “org.robovm:robopods-google-mobile-ads-ios:$roboVMVersion” in the dependencies of the project(“:ios”) in the main build.gradle of my libgdx projects, used ./gradlew eclipse and then imported the projects into Eclipse.

Another option if you don’t want to use graddle or maven is to directly grab the jar files you need (robopods-google-mobile-ads-ios-$robovmVersion.jar and robopods-google-apis-ios$robovmVersion.jar) from the robovm maven directory and add then to your ios project /lib folder (create it if necessary) and add both jar to the build bath.

Now we need to create an implementation of the AdsDisplayInterface in our ios project:

public class ViewController implements AdsDisplayInterface {
 private GADInterstitial interstitial;

 private GADInterstitial createAndLoadInterstitial() {
     //Ad Unit ID of your interstital, from your adMob account. Use the TEST one for now
     GADInterstitial interstitial = new GADInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx");
     interstitial.setDelegate(new GADInterstitialDelegateAdapter() {
         public void didDismissScreen(GADInterstitial ad) {
             ViewController.this.interstitial = createAndLoadInterstitial();
     return interstitial;

 private GADRequest createRequest() {
     GADRequest request = new GADRequest();
     // To test on your devices, add their UDIDs here:
     return request;

 public void loadAds() {
     interstitial = createAndLoadInterstitial();

 public void showAds() {
     if (interstitial.isReady()) {
     } else {
         System.out.println("Interstitial not ready!");


I used this sample application and modified a couple of things to make it work with libgdx. If you need to add banners, check the sample and it should be quite straightforward.

Now we need to modify our IOSLauncher in the libgdx IOS application:

public class IOSLauncher extends IOSApplication.Delegate {

 private GADInterstitial interstitial;

 protected IOSApplication createApplication() {
     Words.setPlatformResolver(new DesktopResolver());

     IOSApplicationConfiguration config = new IOSApplicationConfiguration();
     return new IOSApplication(new Game(new ViewController()), config);

 public static void main(String[] argv) {
     NSAutoreleasePool pool = new NSAutoreleasePool();
     UIApplication.main(argv, null, IOSLauncher.class);

And now it should work :) Your IOS ad will show up whenever you call loadAd() then showAd() in your game.

Hopefully I didn’t forget any steps, otherwise let me know !

New puzzle game! Gem Hunter

I’ve just finished the development of a small game I wanted to do in my spare time, much simpler than my previous game but it’s still quite fun to play.


The game is obviously available for free on the google play store here: Gem Hunter

The game is quite simple, you try to line up rows/columns of the same color to make them dissapear and earn points, to do so, you can change a gem color by tapping on it, but when you do, a new gem appear on the board. Get as much points as you can before the board is full :)

As always, any feedback is welcome, I haven’t tested on all device yet :)

First major update to Word Hunter

It’s been a week since I published the first version of Word Hunter and it’s going quite well. The game is not perfect but I was able to get quite some feedback and act upon it :)

What’s new ?

  • 20 new levels (double of what was available before) with new gameplay mechanisms
  • New dragback mechanism: you can drag back on the previous letter to correct the word
  • 6 new achievements
  • Bug fix for the HTC One
  • Better handling of ads, they shouldn’t show up in game anymore

LVL 21 - New Cages       New gameplay mechanism

LibGDX and Google Play Game Service Integration

I have been hard working on Google Play Game integration in my upcoming game : Word Hunter and I am posting my finding heres. Hopefully it can help someone else :)

Configuring Google Play Game

Log on to the developer console (if you don’t already have an account, you will need to create one for 25$)

Select “Game Services” and follow the instructions to create a new game.

Some notes :

    • Use the debug certificate in your android sdk install folder
      • You will be able to test Google Play Game integration directly when you launch your application from Eclipse without having to sign it with your production certificate
      • But you will have to restart the process all over again once you want to push it to production (…)
    • Use your production certificate that you use to publish your application to google play
      • You will need to sign your APK using your production certificate (right click on your project -> Export as Android Application) and then install this APK on your device to test it
      • And you are done, you can simply publish the game when you are done and it will work

I went with solution #2 since I am publishing my game in Alpha state in Google play and I want my testers to be able to use it

  • DO NOT forget to add your testers email in the list of testers for the GAME, it is a different list than the application testers or even the Alpha testers
  • Do not bother trying to test Google Play Game with your developer account, even if it is marked as a tester, it just doesn’t work. Use another account.

Once you are done, you should get an application ID associated to your game, follow this documentation to make it available in your game (short version, create an ids.xml file in the android res/values folder and add this id in it as a string with name app_id). This is also where you will put the key for your leaderboards/achievements. You will also need to modify your manifest as indicated in the documentation.

Configuring the libGDX Core project

In your Core project, create an interface with all the actions that you want to be able to do from your game. The basis are :

  • Logon
  • Logoff
  • Send a score to the leaderboard
  • Unlock an achievement
  • Show the Score Leaderboard
  • Show the Achievements Screen

Pastebin code

Configuring the Android project

Once this is done, we need to do several things:

First follow the instructions to download the sample apps from here .

You should get the google-play-services-lib when you install the google play service SDK. Add it to your workspace and add it to your Android project as a library (right click on your android projects -> Properties)

From the BaseGameUtils projects, copy the class directly into your Android project.

Now we will modify the Android project MainActivity class.

First it needs to implement the previously created interface, as well as the GameHelper.GameHelperListener interface (from the GameHelper class we just copied) :

public class MainActivity extends AndroidApplication implements LeaderboardInterface, GameHelper.GameHelperListener

In this class, we will need to instantiate a GameHelper and implement the different methods specified in the Interface. Most of this code was inspired/copied from the BaseGameActivity available in the sample Android project.
Once this is done, we need to pass the MainActivity itself as an argument of the initialize method.

Here is the code

Possible improvements :

  • Show a toast when the unlockAchievement method is called by user is not logged in google play
  • Push scores and achievements right after login, in the onSignInSucceeded method

I noticed that by using this method, the Title Bar now appears in game. To solve this issue, simply add the following theme to your main activity in the manifest :


How to use it in game

In your main class in the core libGDX project (the one which implements ApplicationListener), create a variable of type GameServiceInterface and set it using the arguments passed in the constructor :

public class Game implements ApplicationListener {

public GameServiceInterface _leaderboard;

public Game(GameServiceInterface leaderboard){

         this._leaderboard = leaderboard;


And now you can just call/bind _leaderboard.login() or any other method of the GameServiceInterface anytime in your game.

LibGDX and RevMob integration

I figured I would do a small tutorial on this subject since I had to implement it recently on my current project.

I want to display Full Screen RevMob ad in my Android game in between two levels. Displaying banner ads is slightly different and won’t be covered here.

Setup and configure RevMob

  1. First, grab the RevMob SDK from their website, for this tutorial, I will pick Android as the target platform. (You can also check the configuration step from their website for the most up to date instructions)
  2. Copy the revmob-n.n.n.jar in your android project libs’s folder and add it to your build path (in Eclipse, right click on the jar -> Add to build path)
  3. Modify your project’s manifest, add the following permissions
    • <uses-permission android:name="android.permission.INTERNET"/>
    • <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    • <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    • <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> (This one is optional but recommended)
  4. Add the following activity to your manifest (supposing you want to use full screen ads in your application)
    • <activity android:name=”” android:configChanges=”keyboardHidden|orientation”> </activity>
  5. Also don’t forget to create your application in the RevMob console and grab your application ID

Configure LibGDX projects

Next you want to configure your LibGDX projects. Let’s suppose your game is multiplatform and you have an Android, Web, Desktop. You want to display RevMob ads only in your Android game and use another ads platform for Web/Desktop (since RevMob is mobile only) or maybe your desktop version won’t be displaying any ads anyway.

First let’s create an Interface in your main project to specify the actions correspond to the display of ads.

public interface AdsDisplayInterface{
   public void showFullScreenAds();
   public void openAdsLink();

This interface correspond to the different actions you might want to do in your game (for example show a full screen ads between two levels, or open the affiliate link when the “More Applications” button is clicked…)

Now you want to create a class implementing this Interface in the platforms where you want to display ads

In the Android project, we will create the following class

public class RevMobDisplay implements AdsDisplayInterface {
   private static final String REVMOB_APP_ID = &quot;copy your RevMob App ID here&quot;;
   private MainActivity activity;
   private RevMob revmob;

   public RevMobDisplay(MainActivity mainActivity){
      this.activity = mainActivity;
      revmob = RevMob.start(mainActivity, REVMOB_APP_ID);
   public void showFullScreenAds(){

   public void openAdsLink(){
      revmob.openAdLink(activity, listener);

Now, in the main Android class, create an instance of this class and pass it as an argument to the Game constructor:

public class MainActivity extends AndroidApplication {
   public void onCreate(Bundle savedInstanceState) {

      AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();

      initialize(new Game(new RevMobDisplay(this)), cfg);

Eclipse should warn you that there is an error with this modified code because the Game constructor does not expect this argument.So we will create a new constructor that expects this argument in your main project’s Game class (this is the Class that implements ApplicationListener)

public class Game implements ApplicationListener {
   public AdsDisplayInterface _adsDisplay;

   public Game(AdsDisplayInterface adsDisplay){
      _adsDisplay = adsDisplay;

   public Game(){

      public void create() {

Displaying Ads

Now, whenever you want to display a fullscreen ad, you can simply do the following:

if (_adsDisplay!=null){

Remember we only created this class for the Android application, so if we tried to display ads from another platform, it would crash with a null pointer exception, so we check if it is null beforehand.

There you go, let me know if you have any questions in comments.

Scoring System – Balancing and Handling difficulty

It’s been quite some time since I have posted! What have I been up to ?

  • I’ve updated my first game: Cube Overlord for Android.
  • I am waiting for libgdx free iOS publishing solution to come out of beta so I can start publishing on iOS too.
  • And….I’ve started working on a new Game !

My first game was a vertical scroller, I am happy that I did and released it. I am mostly happy about the results but it took quite some time and there are a lot of parts I am not so happy about. For my second game I want a simpler project where I can focus on those parts to improve my skills, so I am going for a puzzle game!

It doesn’t have a name yet but it’s going to be some sort of mix between Boogle and Tetris . The basis is quite simple you combine letters to make words and earn points.

I don’t have much to show yet, but I want to talk about the scoring system.

Most, if not all games nowadays have some kind of scoring system. You get 1, 2, 3…stars at the end of each level (I will refer to this as the “Star” system for the rest of this post), awards, achievements…

Cube Overlord - 3 Stars

Cube Overlord – 3 Stars

The Star System

The logic behind this is that it gives the players more goals to achieve and awards to collect, adding to the replayability of your game. Some players will be satisfied simply completing a level, but other want to beat the game 100% and get all 3 stars for each level. It’s usually good to cater to all kind of players.

Here I am not going to discuss whether or not this is a good idea but I want to talk about how I implemented and balanced this Scoring System in my new game, specifically how I designed my “Star” system

First, let’s talk about the possible criteria for this system:

Point based:

You get a star after you pass a certain threshold. The way the user collect those points is specific to your game and can vary in difficulty

Checkpoint based:

You get a star for a specific action or for filling a specific game condition in the level, there are many possibilities and of course most will be specific to your game. Here are some examples :

  • Finish the level under x seconds
  • Finish the level without getting hit more than x times
  • Collect one or several special/hidden items

This is usually a good idea when you want your users to experience your game in a different ways, explore the level instead of rushing to the exit (or vice versa), play stealthy rather than rush into the battle etc…

All is one

You might be tempted to convert those conditions into points as well:

  • The remaining time is converted into points,
  • The player looses points when  he gets hit
  • Special items gives a set amount of points.

but there are several drawbacks to this method

  1. If there are several ways to earn points, you loose the ability to “orient” the user toward a specific action/gameplay. Which is not a bad thing by itself depending on what kind of game you are going for. Leaving multiple options to earn stars means that you can play the way you want and not be punished, of course this work only if you have viable gameplay alternatives.
  2. You risk complicating the scoring system and making it too opaque for your player.


Cube Overlord

Most games will base their scoring system on points only or on a mix between points and checkpoint. Here is what I did for Cube Overlord:

  1. A star for completing the level (minimum required)
  2. A star when getting more than X points
  3. A star if you completed the level without being hit a set number of times (0 for harder levels)

What does this achieve ? Well in Cube Overlord, there is a mechanic to increase your score multiplier but it requires you to stay in the same color for long period of times, this create a whole new sets of challenges for the player that I will not detail here. If the player only wants to complete the level, then he can play it safe, but if he wants to get this extra star, he will have to use this “optional” game mechanic and engage in this new gameplay.

In this game, I play tested each level several times and estimated the point threshold to get this star based on my own scores. This was quite time consuming and required me to retest each level after a redesign. I didn’t want to make the same mistake this time so I looked into other solutions. (I am not saying you shouldn’t play test your game!).

My new project

For my new game, I decided to base my scoring system solely on points. This is a decision that you have to make on a case to case basis. For me it was quite straightforward, in my game you will get more points by making longer words. There is no reason to add extra incentives such as “Make a 6 letters word to get a star” and since there is already a time based game mode planned I didn’t want to add a time based condition such as “Get X words under Y seconds”. There is nothing stopping me from adding those as Challenges/Awards later on anyway.

Using a point system has the extra advantage that it is easier to decide the thresholds value for each extra stars using a systematic approach:

Warning: The numbers used below are used for this example and may not apply in reality, but the logic remain true.

I have the following point system:

  • 2 letters word : 15  points
  • 3 letters word : 30 points
  • 4 letters word : 50 points
  • 5 letters word : 75 points
  • 6 letters word : 105 points

It’s not linear because the difficulty to find longer words increases exponentially so the point system reflects that.

This is not set in stone but we will use this as a base, I evaluate the difficulty for each possibility:

  • 2 letters word : Very easy
  • 3 letters word : Easy
  • 4 letters word : Medium
  • 5 letters word  : Hard
  • 6 letters word: Very hard

First solution

Let’s say I want my first level to be very easy, and I want it to last about 30 seconds, I evaluate it takes the average user about 3 seconds to make a 2 letters words. So to make the level last 30 seconds, the user will be limited to 10 words (10*3 = 30, my math checks out!). So the target for my first level would be 150 points!

Now I want my players to be able to over achieve and earn extra stars,

  • so for one extra star the difficulty should go from “very easy” to “easy”
  • and for two extra stars it should go up to “medium”.

Let’s say it takes 5 seconds for a player to make a 3 letters word, and 7 seconds for a 4 letter words.

  • So for a 30 second game session, the first extra star will require (30/5 * 30 pts) = 180 points
  • And the second extra star will require (30/7 * 50 pts) = 214

This is not perfect of course, in this case I think I should increase the score for each extra letter, but it’s a good start.

Second solution (not necessary incompatible with the first one)

Let’s say I don’t want players to keep entering words after they get the minimum numbers of points required to finish the level.

Using the numbers from the previous solution:

  • If the user skills correspond to the “very easy” difficulty level, then he will finish the level (150 points required) when he uses up his last move.
  • If the user skills correspond to the “easy” difficulty level (3 letters words), then he will reach 150 points after (150/30) 5 moves, with 5 moves lefts.
  • If the user skills correspond to the “medium” difficulty level (4 letters words), then he will reach 150 points after (150/50) 3 moves, with 7 moves left.

With this information, I can give each moves a set number of points (20 for example), and set the threshold for each star accordingly.

  • Second star : 5 stars left * 20 points = 100 points. Threshold is at 150 + 100 = 250 points
  • Third star : 7 stars left * 20 points = 140 points. Threshold is at 150 + 140 = 290 points

Of course, players will find words of different lengths during the same play session but this even out in average and you should still get a star corresponding to your skill level.

Following this system, it should be quite easy to establish a scoring system adapted to your game. You will need to tweak your numbers for other factors (for example take into account added difficulty in the level design).

First Update to Cube Overlord

This is the first time since the game has been released that I have had enough time to work on it.

Listening to some feedback by players, I implemented the following:

  1. Dying animation: you no longer go straight to the game over screen when you die, the game slow down and your cube fall off the bottom of the screen, only then the GameOver screen shows up. That was much easier that I thought it would be to implement, but it still took quite some time.
  2. Replaced the confusing multi colored cube animation that lets you grow by a a “heart” PowerUp, hopefully it is now obvious that it is a positive thing to pick up :)
  3. Added two new Awards (and ingame “awards unlocked” animation)
  4. Slightly increased the speed of the first levels.
  5. Better UI for android tablets

Otherwise I am working on a Time Trial mode. Hopefully available soon.

You can get the new version here!

Android app on Google Play