Skip to content

Instantly share code, notes, and snippets.

@Leejjon
Created March 1, 2017 01:46
Show Gist options
  • Save Leejjon/019e6f4799cb77d584810fc86704abd9 to your computer and use it in GitHub Desktop.
Save Leejjon/019e6f4799cb77d584810fc86704abd9 to your computer and use it in GitHub Desktop.
Combining the AssetManager with a Texture enumeration

After my previous gist about handling textures in a libGDX game, I am going to combine the libGDX AssetManager with my approach to see if we can get the best of both worlds.

Asset manager

LibGDX has an AssetManager included, in which you can put all your assets, and it will load them for you. After that, you can retrieve them for actually using them. Disposing the asset manager will dispose all textures inside it nicely.

Positives of using an asset manager:

  • Synchronous and Asynchronous asset loading.
  • All assets in one asset manager (fonts, textures, skins, sound files etc).
  • Support for unloading when pausing and resuming your game.
  • Can be extended and since LibGDX is opensource you can alter it.

Negatives of using an asset manager:

  • It uses the file paths (String) of the textures as key.
  • No support for generated textures that aren't loaded from a file.
  • It seemed hard for me to create a proper custom asset loader that supported generated textures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment