Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
LibGDX Game Development By Example

You're reading from   LibGDX Game Development By Example Learn how to create your very own game using the libGDX cross-platform framework

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781785281440
Length 280 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
James Cook James Cook
Author Profile Icon James Cook
James Cook
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting to Know LibGDX FREE CHAPTER 2. Let's Get These Snakes Out of This Book! 3. Making That Snake Slick 4. What the Flap Is the Hype About? 5. Making Your Bird More Flightworthy 6. Onto the Next Platform...Game 7. Extending the Platform 8. Why Are All the Birds Angry? 9. Even Angrier Birds! 10. Exporting Our Games to the Platforms 11. Third-party Services Index

Setting up LibGDX

We know by now that LibGDX is this awesome tool for creating games across many platforms with the ability to iterate on our code at superfast speeds. But how do we start using it?

Thankfully, some helpful people have made the setup process quite easy. However, before we get to that part, we need to ensure that we have the prerequisites installed, which are as follows:

  • Java Development Kit 7+ (at the time of writing, version 8 is available)
  • Android SDK

Not that big a list! Follow the given steps:

  1. First things first. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html.
  2. Download and install the latest JDK if you haven't already done so. Oracle developers are wonderful people and have provided a useful installation guide, which you can refer to if you are unsure on how to install the JDK, at

    http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html.

  3. Once you have installed the JDK, open up the command line and run the following command:
    java -version
    

    If it is installed correctly, you should get an output similar to this:

    Setting up LibGDX
  4. If you generate an error while doing this, consult the Oracle installation documentation and try again.
  5. One final touch would be to ensure that we have JAVA_HOME configured. On the command line, perform the following:
    • For Windows, set JAVA_HOME = C:\Path\ToJDK\
    • For Linux and Mac OSX, export JAVA_HOME = /Path/ToJDK/
  6. Next, on to the Android SDK.

At the time of writing, Android Studio has just been released. Android Studio is an IDE offered by Google that is built upon JetBrains IntelliJ IDEA Java IDE. If you feel comfortable using Android Studio as your IDE, and as a developer who has used IntelliJ for the last 5 years, I suggest that you at least give it a go. You can download Android Studio + Android SDK in a bundle from here:

http://developer.android.com/sdk/index.html

Alternatively, if you plan to use a different IDE (Eclipse or NetBeans, for example) you can just install the tools from the following URL:

http://developer.android.com/sdk/index.html#Other

You can find the installation instructions here:

https://developer.android.com/sdk/installing/index.html?pkg=tools

However, I would like to point out that the official IDE for Android is now Android Studio and no longer Eclipse with ADT.

For the sake of simplicity, we will only focus on making games for desktops for the greater part of this book. We will look at exporting to Android and iOS later on.

Once the Android SDK is installed, it would be well worth running the SDK manager application; so, finalize the set up.

If you opt to use Android Studio, you can access this from the SDK Manager icon in the toolbar. Alternatively, you can also access it as follows:

  • On Windows: Double-click on the SDK's Manager.exe file at the root of the Android SDK directory
  • On Mac/Linux: Open a terminal and navigate to the tools/ directory in the location where the Android SDK is installed, then execute Android SDK.

The following screen might appear:

Setting up LibGDX

As a minimum configuration, select:

  • Android SDK Tools
  • Android SDK Platform-tools
  • Android SDK Build-tools (latest available version)
  • Latest version of SDK Platform

Let them download and install the selected configuration. Then that's it!

Well, not really. We just need to set the ANDROID_HOME environment variable. To do this, we can open up a command line and run the following command:

  • On Windows: Set ANDROID_HOME=C:/Path/To/Your/Android/Sdk
  • On Linux and Mac OS X: Export ANDROID_HOME=/Path/To/Your/Android/Sdk

Phew! With that done, we can now move on to the best part—creating our first ever LibGDX game!

You have been reading a chapter from
LibGDX Game Development By Example
Published in: Aug 2015
Publisher:
ISBN-13: 9781785281440
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime