Preface

Libgdx is a powerful Java-based open source cross-platform game framework. It allows developers to target Windows, Mac, Linux, Android, iOS, and HTML5 with a single codebase, sparing them the hassle of dealing with low-level, platform-specific details.

Preface

For more information, please refer to http://libgdx.badlogicgames.com/.

Through a clean and simple API, Libgdx offers a vast set of features, which are as follows:

  • Low-level OpenGL access: This includes vertex arrays, meshes, framebuffers, shaders, and immediate mode renderer
  • 2D graphics: This includes bitmaps, texture atlases, particles, scene graph, user interface, and maps
  • 3D graphics: This includes model loading, lighting, decal batching, particles, and so on
  • Audio: This includes streaming music, sound effects (MP3, WAV, and OGG), pitch control, and direct access to recording devices
  • Input: This includes keyboard, mouse, touch, accelerometer, compass, and controller events as well as gesture detection
  • Math and physics: This includes matrices, vectors, shapes, interpolators, frustum, intersection utilities, and full Box2D and Bullet physics JNI wrappers
  • File I/O: This includes cross-platform file access, preferences storage, XML, and JSON parsing
  • Utilities: This includes fast custom collections and easy multiresolution handling
  • Tools: This includes project creation, particle editor, bitmap font generator, and texture packer

Libgdx is incredibly fast, thanks to the use of JNI wrappers and heavy emphasis on avoiding garbage collection. This becomes crucial when deploying on mobile devices and browsers. Its framework nature allows you to choose which components to use as it does not enforce a single way of working like most engines do.

The community behind the framework is large, welcoming, and always willing to provide support. The GitHub repository shows how active the project is, with many commits every day, constant releases, and rich documentation. For more information, refer to https://github.com/libgdx/libgdx.

Thanks to its permissive Apache 2.0 license, Libgdx can be used for both commercial and noncommercial projects without having to necessarily disclose the source. According to AppBrain, 1.44 percent of all the Android applications (both games and nongames) are built on top of it, which reinforces its flexibility and ease of use. For more information, refer to http://appbrain.com/stats/libraries/details/libgdx/libgdx.

This book provides excellent coverage of the aforementioned systems focusing on 2D game development. Each chapter covers a set of related features through a series of recipes. A recipe explains with simple steps how to carry out a particular task with Libgdx such as rendering a texture on the screen. The practical approach will give you a very good insight on how things actually work, preparing you to use this technology on real-life projects.

After reading through the recipes in this book, you will have a solid understanding of how all the systems in Libgdx work and how to better leverage them in order to implement your games. The good practices exposed here will give you an edge to produce clean and efficient code.