Before we will be create our first libGDX application, we need to set up the environment with right version of libGDX. In our application, we will be use the last version of libGDX (1.7.0 version at the time of this post). To get the last version of libGDX, clone an official libGDX repository from GitHub. To do this, execute this command:

gitclonehttps://github.com/libgdx/libgdx.git

After that, build the libGDX Library using these commands:

ant-ffetch.xmlmvninstall

After this build completes, we will have libGDX version with support of Multi-OS Engine in our local maven repository. So we can start to develop our application.

We created all the screens for our game. So now we should create some models such as Player, Naves and others for our game. Create a new module models and create the base class GameObject for all objects in our game.

To develop the Android part of our app, modify the build.gradle for your Android project (app/build.gradle). We need to add to dependencies on some libGDX libraries. We also need to copy native libGDX libraries to our project. Please write this code in app/build.gradle:

Now we can create Main class for our Android application. Let’s create a class named Main. Modify the AndroidManifest.xml file to add to it our activity (Main class). You can see the revised AndroidManifest.xml below.

Next, modify our Main class to create a libGDX Android activity. It is not hard. We need add AndroidApplication from& com.badlogic.gdx.backends.android as parent of the Main class and override the onCreate function.

Finally, add images, sounds and others asset files for our game. You can download these files from here (All resources were taken from this project and they are distributed under MIT license). After you download these files (archive), create a directory named assets in your source directory tree for your Android application. Extract these downloaded files to the assets folder.

Congratulations! We completed our Android game. Now we can build and run the game! You can see the running app in the screen shot below.

Now we will modify the Xcode project. Right-click its name and select Multi-OS Engine > Open Project in Xcode.

The Xcode project will be opened and we should see the next screen:

Remove MainUI.storyboard in the Resources directory.

Next, add resources to Xcode. Click the right mouse button on the Resources directory and choose add files to our project. Next, find our resources in our project (You can use resources from you android module or download from here). All resources were taken from this project and they are distributed under MIT license) and add it to the Xcode project. The result you can see below.

Add libGDXLibrary to the Xcode project by changing Linker Flags in Build Settings > Linking >Other Linker Flags and add to it the following parameters:

We can now explore how you can debug your libGDX application. The libGDX debug process is not specific, so we can debug our libGDX game as usual Multi-OS Engine app. To begin, set some breakpoints.

For example, set two breakpoints in our common code part. First, set a breakpoint at the start of game creating function (create()) at line 15 (MissleCommand.java:MissleCommand.create():15).

Set the second breakpoint in file MainMenuScreen.java line 55 (start of draw function). (MainMenuScreen. MainMenuScreen.draw():55).

Now we can run our application with debugging. While debugging, use all opportunities to debug your code such as Step Over, Step Into, Resume program. Also you can use stack trace to help debug your application.

Use a stack trace to see values of variables on a previous step. You can see it below.