Class Resources

java.lang.Object
de.gurkenlabs.litiengine.resources.Resources

public final class Resources extends Object
This class is the engines entry point for accessing any kind of resources. A resource is any non-executable data that is deployed with your game. The Resources class provides access to types of ResourcesContainers and is used by different (loading) mechanisms to make resources available during runtime.

The LITIENGINE supports a variety of different resource types, including:

  • images
  • fonts
  • maps
  • (localizable) strings
  • spritesheets
  • sounds
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static Blueprints
    Gets the container that manages Blueprint resources.
    static void
    Clears the all resource containers by removing previously loaded resources.
    static Fonts
    Gets the container that manages Font resources.
    get(String file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    get(URL file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    static URL
     
    static Images
    Gets the container that manages BufferedImage resources.
    static void
    load(String gameResourceFile)
    Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor.
    static void
    load(URL gameResourceFile)
    Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor.
    static Maps
    Gets the container that manages IMap resources.
    static String
    read(String file)
    Reads the specified file as String from either a resource folder or the file system.
    Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
    static String
    read(String file, Charset charset)
    Reads the specified file as String from either a resource folder or the file system.
    static String
    read(URL file)
    Reads the specified file as String from either a resource folder or the file system.
    Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
    static String
    read(URL file, Charset charset)
    Reads the specified file as String from either a resource folder or the file system.
    static Sounds
    Gets the container that manages Sound resources.
    Gets the container that manages Spritesheet resources.
    static Strings
    Gets a container that manages String resources.
    This instance can be used to access localizable string from a ".properties" file.
    static Tilesets
    Gets the container that manages Tileset resources.
    This implementation uses raw Tilesets, to avoid problems with Tileset methods that aren't in the ITileset interface.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fonts

      public static Fonts fonts()
      Gets the container that manages Font resources.
      Returns:
      The Font resource container.
      See Also:
    • sounds

      public static Sounds sounds()
      Gets the container that manages Sound resources.
      Returns:
      The Sound resource container.
      See Also:
    • maps

      public static Maps maps()
      Gets the container that manages IMap resources.
      Returns:
      The IMap resource container.
      See Also:
    • tilesets

      public static Tilesets tilesets()
      Gets the container that manages Tileset resources.
      This implementation uses raw Tilesets, to avoid problems with Tileset methods that aren't in the ITileset interface.
      Returns:
      The Tileset resource container.
      See Also:
    • strings

      public static Strings strings()
      Gets a container that manages String resources.
      This instance can be used to access localizable string from a ".properties" file.
      Returns:
      The String resource container.
    • images

      public static Images images()
      Gets the container that manages BufferedImage resources.
      Returns:
      The BufferedImage resource container.
      See Also:
    • spritesheets

      public static Spritesheets spritesheets()
      Gets the container that manages Spritesheet resources.
      Returns:
      The Spritesheet resource container.
      See Also:
    • blueprints

      public static Blueprints blueprints()
      Gets the container that manages Blueprint resources.
      Returns:
      The Blueprint resource container.
      See Also:
    • load

      public static void load(String gameResourceFile)
      Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor. After loading, these resources can be accessed via this API (e.g. Resources.maps().get("mapname").
      Parameters:
      gameResourceFile - The file name of the game resource file
    • load

      public static void load(URL gameResourceFile)
      Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor. After loading, these resources can be accessed via this API (e.g. Resources.maps().get("mapname").
      Parameters:
      gameResourceFile - The URL to the game resource file
    • get

      public static InputStream get(String file)
      Gets the specified file as InputStream from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as InputStream.
      See Also:
    • get

      public static InputStream get(URL file)
      Gets the specified file as InputStream from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as InputStream.
      See Also:
    • read

      public static String read(String file)
      Reads the specified file as String from either a resource folder or the file system.
      Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(String file, Charset charset)
      Reads the specified file as String from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      charset - The charset that is used to read the String from the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(URL file)
      Reads the specified file as String from either a resource folder or the file system.
      Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(URL file, Charset charset)
      Reads the specified file as String from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      charset - The charset that is used to read the String from the file.
      Returns:
      The contents of the specified file as String
    • clearAll

      public static void clearAll()
      Clears the all resource containers by removing previously loaded resources.
    • getLocation

      public static URL getLocation(String name)