Skip to content
Matheus Pimenta edited this page Mar 29, 2014 · 19 revisions

#Tutorial navigation

  • [Previous: Basics 5 (Rendering)](Basics 5 (Rendering))
  • Current: Basics 6 (Assets)
  • [Next: Basics 7 (IO)](Basics 7 (IO))

#AssetManager

This class knows how to load images, audio, fonts and maps (from text files). It is used mainly by asset classes (next section) to load files, but you can call its methods by yourself, if your intention is to implement lower level operations than the provided by asset classes. If a file is already loaded in the container, it just returns the reference. An AssetManager named assets is provided by each GameScene, so files are loaded more than once, if requested to different AssetManager instances. The methods provided by this class are:

  • Texture AssetManager.getTexture(String path) Get a org.newdawn.slick.opengl.Texture passing its path.
  • Font AssetManager.getFont(String path) Get a java.awt.Font passing its path.
  • OggInputStream AssetManager.getOggInputStream(String path) Get a org.newdawn.slick.openal.OggInputStream passing its path.
  • Map AssetManager.getMap(String path) Get a org.unbiquitous.uImpala.engine.asset.Map passing a text file path.

#Asset classes

Asset classes frequently receive a reference to AssetManager and zero or more paths to files in their constructors. You shall never forget that AssetManager adds the game's root path as prefix automatically. With these constructors and methods that receive an OutputResource object (see the next tutorial), these classes implement operations to put things out, like render images, play audio, draw text, etc. There are many asset classes, but they are very simple to use. A quick reading in the documentation (available in the source code) is enough to learn how to use these classes. Remember that it's a good practice to create assets inside GameScene constructors.

#Tutorial navigation

  • [Previous: Basics 5 (Rendering)](Basics 5 (Rendering))
  • Current: Basics 6 (Assets)
  • [Next: Basics 7 (IO)](Basics 7 (IO))
Clone this wiki locally