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
Mastering LibGDX Game Development

You're reading from   Mastering LibGDX Game Development Leverage the power of LibGDX to create a fully functional, customizable RPG game for your own commercial title

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781785289361
Length 420 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Patrick Hoey Patrick Hoey
Author Profile Icon Patrick Hoey
Patrick Hoey
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. As the Prophecy Foretold, a Hero is Born 2. Welcome to the Land of BludBourne FREE CHAPTER 3. It's Pretty Lonely in BludBourne… 4. Where Do I Put My Stuff? 5. Time to Breathe Some Life into This Town 6. So Many Quests, So Little Time… 7. Time to Show These Monsters Who's the Boss 8. Oh, No! Looks Like Drama! 9. Time to Set the Mood 10. Prophecy Fulfilled, Our Hero Awaits the Next Adventure Index

Understanding the high-level component layout of LibGDX

We are now going to review the architecture behind LibGDX. As a quick note, the latest stable release of LibGDX that we are going to use throughout this book is version 1.5.5, which was built on 19 March, 2015.

LibGDX backend modules

The following figure (Figure 4) is a diagram illustrating the core interfaces of LibGDX. These are the highest level abstractions available that provide most of the functionality you will need when creating your game (including their associated module libraries):

LibGDX backend modules

Figure 4

These interfaces are implemented for each of the currently supported target platforms, allowing you to develop your game once, using these APIs and not having to worry about platform-specific issues. An overview of the functionality that each interface contains (once implemented for each supporting platform) is as follows:

  • Application.java: This interface becomes the entry point that the platform OS uses to load your game. Each implementation will be responsible for setting up a window, handling resize events, rendering to the surfaces, and managing the application during its lifetime. Specifically, Application.java will provide the modules for dealing with graphics, audio, input and file I/O handling, as well as logging facilities, memory footprint information, and hooks for extension libraries.
  • Graphics.java: This interface contains numerous helper methods for communicating with the platform's graphics processor, such as rendering to the screen and querying for available display modes such as graphics resolution and color depth. There are also convenience methods for generating pixmaps and textures. One interesting note is that for cross-platform support, the underlying graphics API (OpenGL ES 2.0 or OpenGL ES 3.0) is emulated for the desktop by mapping OpenGL ES functions to the desktop OpenGL functions.
  • Audio.java: This interface contains numerous helper methods for creating and managing various audio resources. This interface helps to create sound effects, play music streams, and give direct access to the audio hardware for PCM audio input and output.
  • Files.java: This interface contains numerous helper methods for accessing the platform's filesystem when managing game assets such as reading and writing files. This abstraction over the different types of file locations includes internal files (located in your game working directory) and external files (external storage such as an SD card).
  • Input.java: This interface contains numerous helper methods to poll (or process events) for user input from not only standard input such as keyboard key presses and mouse button clicks, but also mobile device input such as touch screens and accelerometer updates. Other helper methods include handling vibrations, compass access, on-screen keyboard input, and cursor capture.
  • Net.java: This interface contains numerous helper methods for performing certain network-related operations, such as managing HTTP/HTTPS GET and POST requests and creating TCP server/client socket connections.
  • Preferences.java: This interface contains numerous helper methods for storing and accessing application game setting values as a lightweight setting storage mechanism.

LibGDX core modules

The rest of the functionality that you will use for your game belongs to a host of core modules within the LibGDX framework:

LibGDX core modules

Figure 5

The modules in the left column (audio, files, graphics, input, and net) in Figure 5 were already discussed previously in Figure 4. The other modules are as follows:

  • Maps: This module contains classes for dealing with different level map implementations, such as maps generated from Tiled (an XML-based format called TMX) and Tide. The convenience methods include handling the loading of the map and referenced assets, rendering the map, accessing properties, and selecting different layers.
  • Math: This module contains classes with convenient utility methods for dealing with various mathematical calculations such as trigonometry, linear algebra, and probability. These methods are also optimized to be fast. Other classes include geometric classes for dealing with shapes, areas, and volumes, collision detection tests such as intersection and overlap, and interpolation algorithms.
  • Assets: This module contains classes for managing the loading and storing of assets such as textures, bitmap fonts, particle effects, pixmaps, UI skins, tile maps, sounds, and music. These classes will also deal with different caching strategies to optimize the storage and use of your game assets.
  • Scenes: This module contains classes for building 2D scene graphs used in creating UIs such as game menus and HUD overlays. This module also provides classes for managing the laying out, drawing, and handling input for the different UIs.
  • Utils: This module is more of a catchall for various miscellaneous pieces of utility methods that don't quite fit anywhere else. This module supports reading and writing in XML and JSON (with serialization support), custom collections with primitive type support (which helps to avoid performance hits when autoboxing types), timers, and object pools.

There are other libraries that come with LibGDX, but typically maintained by third parties. These will fall under the extensions folder. The LibGDX extensions folder includes the following:

  • gdx-box2d: This is a physics engine for 2D rigid bodies
  • gdx-bullet: This is a real-time physics simulation library
  • gdx-controllers: This is for gamepad and joystick controller support
  • gdx-freetype: This generates bitmap fonts on the fly from one TrueType font (TTF) file
  • gdx-jnigen: This allows C/C++ code to be written inline with Java source code
  • gdx-setup: This is the UI project setup application used to manage LibGDX installs with the Gradle build system
  • gdx-tools: This is a miscellaneous collection of tools to aid in the development of your game, such as a particle effect editor, a texture packer application, and a bitmap font creator utility
lock icon The rest of the chapter is locked
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