Free Sample
+ Collection

Libgdx Cross-platform Game Development Cookbook

Cookbook
David Saltares Márquez, Alberto Cejas Sánchez

Over 75 practical recipes to help you master cross-platform 2D game development using the powerful Libgdx framework
$29.99
$49.99
RRP $29.99
RRP $49.99
eBook
Print + eBook

Want this title & more?

$21.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783287291
Paperback516 pages

About This Book

  • Gain an in-depth understanding of every Libgdx subsystem, including 2D graphics, input, audio, file extensions, and third-party libraries
  • Write once and deploy to Windows, Linux, Mac, Android, iOS, and browsers
  • Full of uniquely structured recipes that help you get the most out of Libgdx

Who This Book Is For

If you want to make cross-platform games without the hassle and dangers of writing platform-specific code, or If you are a game programmer who may have some experience with Java and you want to learn everything you need to know about Libgdx to produce awesome work, this is the book for you.

To take full advantage of the recipes in this book, you are expected to be familiar with java with good game programming knowledge.

Table of Contents

Chapter 1: Diving into Libgdx
Introduction
Setting up a cross-platform development environment
Creating a cross-platform project
Understanding the project structure and application life cycle
Updating and managing project dependencies
Using source control on a Libgdx project with Git
Importing and running the Libgdx official demos
Chapter 2: Working with 2D Graphics
Introduction
Texture rendering with SpriteBatch
More effective rendering with regions and atlases
Taking advantage of Libgdx sprites
Rendering sprite-sheet-based animations
Understanding orthographic cameras
Using ShapeRenderer for debug graphics
Handling multiple screen sizes with viewports
Chapter 3: Advanced 2D Graphics
Introduction
Achieving juicy effects with particles
Frame buffers and image composition
Welcome to the world of shaders
Passing parameters into shader programs
2D depth of field shader
Embedding a Libgdx window into a Java desktop application
Chapter 4: Detecting User Input
Introduction
Detecting user input via event polling
Detecting user input via event listening
Managing multiple listeners at once
Detecting more complex gestures
Introducing the controllers API
Input mapping for cross-platform development
Chapter 5: Audio and File I/O
Introduction
Playing short sound effects
Audio streaming for background music
Optimizing audio files to reduce download sizes
Procedural audio generators
Engine sounds with dynamic audio
The 2D space sound system
The first approach to file handling in Libgdx
Using preferences to store game states and options
The XML parsing primer
JSON serialization and deserialization
Chapter 6: Font Rendering
Introduction
Generating and rendering bitmap fonts
Baking effects into fonts using Hiero
Scaling friendly font rendering with distance fields
Dynamic font effects using distance fields
Chapter 7: Asset Management
Introduction
Getting to know AssetManager
Asynchronous asset loading
Creating custom asset loaders
Managing groups of assets for bigger games
Chapter 8: User Interfaces with Scene2D
Introduction
Introducing the Scene2D API
Widget collection overview
Creating a basic menu screen using tables
Skin customization
Creating new widgets
Chapter 9: The 2D Maps API
Introduction
Creating maps with Tiled and loading them into Libgdx
Adding and querying map metadata
Developing your own map loaders and renderers
Chapter 10: Rigid Body Physics with Box2D
Introduction
Introducing Box2D
Introducing more complex shapes
Introducing joints
Real-life joints example – bike simulator
Reacting to collisions
Sensors and collision filtering
Querying the world
Building a physics world from level data
Implementing a deferred raycaster
The fixed timestep approach
Chapter 11: Third-party Libraries and Extras
Introduction
Making libraries compatible with GWT
Managing platform-specific code
Smooth animations with Universal Tween Engine
Dynamic 2D lighting with Box2DLights
Adding support for localization
Finite state machine and messaging
Component-based entity systems with Ashley
Skeletal animations with Spine
Chapter 12: Performance and Optimizations
Introduction
Profiling your application with VisualVM
Using Libgdx features to avoid garbage collection
Avoiding unnecessary render calls with frustum culling
Chapter 13: Giving Back
Introduction
Releasing your Libgdx game on desktop
Releasing your Libgdx game on Android
Releasing your Libgdx game on iOS
Releasing your Libgdx game on browsers
Working from sources
Creating a new test for your fresh feature
Sending a pull request on GitHub

What You Will Learn

  • Wield the power of the 2D graphics API; get to grips with textures, atlases, particles, fonts, and shaders
  • Manage input from different devices, including touch, keyboard, mouse, gamepad, and accelerometer
  • Increase player immersion with the Libgdx audio API
  • Quickly design maps with an editor and load them directly into your game
  • Exploit the 2D stage features to build great user interfaces
  • Create amazing physics simulations with Box2D
  • Master the deployment process and reach a wide audience

In Detail

Libgdx is a very popular open source, cross-platform, Java-based game development framework that enables you to write your code once and deploy it to Windows, Mac, Linux, Android, iOS, and browsers.

Supported by code samples for each topic, this book will take you through the features of Libgdx, from the very basic aspects to the most advanced ones. Beginning with an overview of the framework and project creation, the book moves on to the 2D graphics API that enables you to create efficient and visually rich games. You will then explore input detection and audio and file handling, followed by details of how to make use of amazing features such as Box2D rigid body physics, lighting, and artifical intelligence techniques to name a few. You will also discover how to modify Libgdx to suit your needs and share your creation with the world.

Authors

Read More