Class Resources

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

public final class Resources
extends java.lang.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:
ResourcesContainer
  • Method Summary

    Modifier and TypeMethodDescription
    static Blueprintsblueprints()
    Gets the container that manages Blueprint resources.
    static voidclearAll()
    Clears the all resource containers by removing previously loaded resources.
    static Fontsfonts()
    Gets the container that manages Font resources.
    static java.io.InputStreamget​(java.lang.String file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    static java.io.InputStreamget​(java.net.URL file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    static java.net.URLgetLocation​(java.lang.String name) 
    static Imagesimages()
    Gets the container that manages BufferedImage resources.
    static voidload​(java.lang.String gameResourceFile)
    Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor.
    static voidload​(java.net.URL gameResourceFile)
    Load Spritesheets, Tilesets and Maps from a game resource file created with the utiLITI editor.
    static Mapsmaps()
    Gets the container that manages IMap resources.
    static java.lang.Stringread​(java.lang.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 java.lang.Stringread​(java.lang.String file, java.nio.charset.Charset charset)
    Reads the specified file as String from either a resource folder or the file system.
    static java.lang.Stringread​(java.net.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 java.lang.Stringread​(java.net.URL file, java.nio.charset.Charset charset)
    Reads the specified file as String from either a resource folder or the file system.
    static Soundssounds()
    Gets the container that manages Sound resources.
    static Spritesheetsspritesheets()
    Gets the container that manages Spritesheet resources.
    static Stringsstrings()
    Gets a container that manages String resources.
    This instance can be used to access localizable string from a ".properties" file.
    static Tilesetstilesets()
    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:
      Font
    • sounds

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

      public static Maps maps()
      Gets the container that manages IMap resources.
      Returns:
      The IMap resource container.
      See Also:
      IMap
    • 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:
      Tileset
    • 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:
      BufferedImage
    • spritesheets

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

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

      public static void load​(java.lang.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​(java.net.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 java.io.InputStream get​(java.lang.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:
      Resources
    • get

      public static java.io.InputStream get​(java.net.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:
      Resources
    • read

      public static java.lang.String read​(java.lang.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 java.lang.String read​(java.lang.String file, java.nio.charset.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 java.lang.String read​(java.net.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 java.lang.String read​(java.net.URL file, java.nio.charset.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 java.net.URL getLocation​(java.lang.String name)