Book Image

Learning Libgdx Game Development

By : Andreas Oehlke, Andreas Oehlke
Book Image

Learning Libgdx Game Development

By: Andreas Oehlke, Andreas Oehlke

Overview of this book

Game development is a field of interdisciplinary skills, which also makes it a very complex topic in many respects. One decision that usually needs to be made at the beginning of a game development processis to define the kind of computer system or platform the game will be developed for. This does not pose any problems in general but as soon as the game should also be able to run on multiple platforms it will become a developer's nightmare to maintain several distinct copies of the same game. This is where the libGDX multi-platform game development framework comes to the rescue! "Learning Libgdx Game Development" is a practical, hands-on guide that provides you with all the information you need to know about the libGDX framework as well as game development in general so you can start developing your own games for multiple platforms. You will gradually acquire deeper knowledge of both, libGDX and game development while you work through twelve easy-to-follow chapters. "Learning Libgdx Game Development" will walk you through a complete game development cycle by creating an example game that is extended with new features over several chapters. These chapters handle specific topics such as organizing resources, managing game scenes and transitions, actors, a menu system, using an advanced physics engine and many more. The chapters are filled with screenshots and/or diagrams to facilitate comprehension. "Learning Libgdx Game Development" is the book for you if you want to learn how to write your game code once and run it on a multitude of platforms using libGDX.
Table of Contents (19 chapters)
Learning Libgdx Game Development
About the Author
About the Reviewers

Features of Libgdx 0.97

Since the release of Libgdx Version 0.1 back in March 2010, a lot of work has been contributed in order to improve this library. The latest stable release of Libgdx is version 0.97 from November 2012, which we are going to use throughout this book.

Here is the list of features taken from the official website (


  • Rendering through OpenGL ES 1.x and 2.0 on all platforms

  • Custom OpenGL ES 2.0 bindings for Android 2.0 and above

  • Low-level OpenGL helpers:

    • Vertex arrays and vertex buffer objects

    • Meshes

    • Textures

    • Framebuffer objects (GLES 2.0 only)

    • Shaders, integrating easily with meshes

    • Immediate mode rendering emulation

    • Simple shape rendering

    • Automatic software or hardware mipmap generation

    • ETC1 support (not available in JavaScript backend)

    • Automatic handling of OpenGL ES context loss that restores all textures, shaders, and other OpenGL resources

  • High-level 2D APIs:

    • Custom CPU side bitmap manipulation library

    • Orthographic camera

    • High-performance sprite batching and caching, and handling OpenGL ES 1.x and 2.0 differences transparently

    • Texture atlases with whitespace stripping support, which are either generated offline or online

    • Bitmap fonts (does not support complex scripts like Arabic or Chinese), which are either generated offline or loaded from TTF files (unsupported in JavaScript backend)

    • 2D Particle system

    • TMX tile map support

    • 2D scene-graph API

    • 2D UI library, based on scene-graph API, and fully skinable

  • High-level 3D APIs:

    • Perspective camera

    • Decal batching for 3D billboards or particle systems

    • Basic loaders for Wavefront OBJ and MD5

    • Work in progress: MD2, Ogre XML and FBX support, and 3D rendering API with materials and lighting system


  • Streaming music and sound effect playback for WAV, MP3, and OGG

  • Direct access to audio device for PCM sample playback and recording (unsupported in JavaScript backend)

  • Decoders for OGG and MPG3 formats (unsupported in JavaScript backend)

  • Pitch shifting, time stretching, and playback rate modification (unsupported in JavaScript backend)

Input Handling

  • Using abstractions for mouse and touchscreen, keyboard, accelerometer, and compass.

  • Gesture detector: detects taps, panning, flinging, and pinch zooming.

  • Gdx remote: to control your desktop application via your Android phone. Useful to test multi-touch gestures while debugging your desktop application.

File I/O

  • Filesystem abstraction for all platforms

  • Read-only filesystem emulation for JavaScript backend

  • Binary file support for JavaScript backend

  • Preferences for lightweight setting storage

Math and Physics

  • Matrix, vector, and quaternion classes. Matrix and vector operations are accelerated via native C code where possible.

  • Bounding shapes and volumes.

  • Frustum class, for picking and culling.

  • Catmull-Rom splines.

  • Common interpolators.

  • Concave polygon triangulation.

  • Intersection and overlap testing.

  • JNI wrapper for Box2D physics. It is so awesome that other engines use it as well.

  • Experimental JNI Wrapper for bullet physics.


  • Custom collections with primitive support

  • JSON writer and reader with POJO (de-)serialization support

  • XML writer and reader


  • Gdx Setup UI for easy project setup

  • Particle editor

  • Texture packer

  • Bitmap font generator