Getting Started with LibGDX for Android Game Development

Getting the Development Environment Ready

1) Install Java Development Kit (JDK)
2) Install Eclipse
3) Install and Configure Android Software Development Kit(SDK)
4) Download Libgdx

Prerequisites

The tutorial will assume a certain level of familiarity with Java language.

I also assume a basic level of familiarity with Android API assuming you understand basic terms like Manifest, Activity, Services, Intent and others. If not, may I first suggest you to read the official API documentation, or watch this excellent video and develop some hello world kind of application before you attempt developing a game.

I will try to cover most of the other things that I assume you not to know :)

Setting up The project:

There are many ways in which you can set up a libGDX project on your Eclipse IDE. You can either use a GUI tool to automate the process or you can set it up manually.

I will not set it up either of the ways. This is because when you set libGDX either of the ways, you create a lot of sections in the workspace Рeach catering to one particular platform. So your code has a section that caters to desktop, a section that caters to Android device, another section to cater to browser based game and so on. And then you have one section that glues it all together to avoid code  repetition in each different platform implementation.

Since for now I am only interested in developing an Android game, I will not go the prescribed libgdx way. Instead I will set up a Android  project the Android way and simply import libGDX as a library into my project.

Don’t worry. Even if you later decide to port your game to other environments, it will not be very difficult. Doing so will let me concentrate on the topic of game development without digressing on platform specific issues.

Meet LibGDX

Let us spend some time getting to know Libgdx before we dive into actual game programming.

So what will LibGDX do for us ? To get a feel of it go and take a careful look at its features.

Once you have had a high level overview of Libgdx feature sets, go and briefly spend some time at its API documentation. Libgdx API is best assessed through its Javadocs. Just read through them here, or check your local copy in the library you downloaded.

Just spend a couple of minutes there before you come back here. Just want you to note that libGDX has grown into a huge package over time. Some the top level packages in LibGDX are as follows:

Each of these packages has sub-packages and each package has many classes. We do not need to know all of them for now but atleast by seeing this you should be able to make a fair guess on the package that you will need to refer for handling a particular task in your hand.

Here’s then a quick quiz.

1. If you had to handle a multi touch event for your game, which of the above package would you most likely find your cure ?

2. Which package would you turn for managing your fixed assets(Any Hints ? )

3. Which package woulod help you manage your preferences or high-score file ?

So each package out there specializes at some tasks and you know which one would be your best choice given your nature of task. I think you get it !

The next section gets your hands dirty with some actual coding.