Android Studio and Libgdx Setup

Android Studio

https://developer.android.com/studio

Java Download

Download Java Here

Libgdx Setup

We’ll be using the LibGDX game development framework throughout this entire summer program, so it’s important that you set up your project correctly before you start coding! We’ll be using the Android Studio IDE to teach, but obviously you have the freedom to use whatever IDE you would like, but we might not be able to help you out with any IDE specific issues.

LibGDX provides a very simple setup tool that basically creates all the base files and helps download everything that you would need to get started.

Link to download LibGDX setup .jar: https://libgdx.badlogicgames.com/download.html

Remember to open the .jar file with the JAR launcher and not to unpack it!

After opening the .jar file, you should see something like the image above. The details for each field is as follows:

  • Name
    Name of your project
  • Package
    Java package for your application, usually a domain you own
  • Game class (this would be covered in the next topic)
    The main game class name
  • Destination
    The destination for project generation, it’s recommended you create a folder and select that folder as the destination.
  • Android SDK
    The path to your Android SDK can be found through your Android Studio > Preferences > Appearance and Behaviour > System Settings > Android SDK. Refer to the video if you’re still unsure where it’s located
  • Sub Projects
    What platforms you want your game to be able to be runnable on
  • Extensions
    Hovering over each of them gives you a short description of what they do. We won’t necessarily cover all the extensions throughout this course, but here’s a short description on what each of them does with links to more information/their docs:
    • Bullet: 3D Collision Detection and Rigid Body Dynamics Library.
    • FreeType: Scalable font. Great to manipulate font size dynamically. However be aware that it does not work with HTML target if you cross-compile for that target.
    • Tools Set of tools including: particle editor (2d/3d), bitmap font and image texture packers.
    • Controller Library to handle controllers (e.g.:Xbox 360 controller).
    • Box2d: Box2D is a 2D physics library.
    • Box2dlights: 2D lighting framework that uses box2d for raycasting and OpenGL ES 2.0 for rendering.
    • Ashley: A tiny entity framework.
    • Ai: An artificial intelligence framework.

Importing into Android Studio

Simply press Open, and then select the whole folder where all your generated game files are located. Wait for Gradle to finish importing and loading. In order to run your game, you’ll need to create a new Run Configuration. You can edit your run configurations through here:

  1. Add a new Application Configuration, rename configuration to Desktop (or anything you want as long as you know it’s the desktop run config.
  2. For the Main class, select DesktopLauncher.
  3. For the classpath of module, select the desktop module.
  4. Press Apply, then OK.

Now, try running your project (with the Desktop config), and a window like this should pop up. If it does, then it means you’ve set up your project and IDE correctly and you’re good to go!

Video Lesson