Book Image

LibGDX Game Development By Example

By : James Cook
Book Image

LibGDX Game Development By Example

By: James Cook

Overview of this book

Table of Contents (18 chapters)
LibGDX Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Packing textures


Currently, we have our textures as individual files. For a game the size of Flappee Bee, that would normally be OK, since during the game we have four files. However, what would happen if we started adding more and more in-game textures? Eventually, we would start slowing down the game. The reason for this is that the underlying OpenGL is performing something called a bind for every different texture it renders. Binding is relatively expensive. To combat this, we can combine our assets into a single sheet, ah! You might be thinking, "But now I have to know where in the sheet the image is?", "What pixels to cut out?", and "What if they are rotated or white-space trimmed to save space in the image?" Well, fear not; LibGDX has a tool for this that will save us time—TexturePacker.

Note

Here is a link to the LibGDX wiki that will let you look deeper into the Texture Packer tool:

https://github.com/libgdx/libgdx/wiki/Texture-packer

However, before we do this, let me first show you...