Class Resources
java.lang.Object
de.gurkenlabs.litiengine.resources.Resources
public final class Resources
extends java.lang.ObjectThis 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 Type Method Description static Blueprintsblueprints()Gets the container that managesBlueprintresources.static voidclearAll()Clears the all resource containers by removing previously loaded resources.static Fontsfonts()Gets the container that managesFontresources.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 managesBufferedImageresources.static voidload(java.lang.String gameResourceFile)LoadSpritesheets,TilesetsandMapsfrom a game resource file created with the utiLITI editor.static voidload(java.net.URL gameResourceFile)LoadSpritesheets,TilesetsandMapsfrom a game resource file created with the utiLITI editor.static Mapsmaps()Gets the container that managesIMapresources.static java.lang.Stringread(java.lang.String file)Reads the specified file as String from either a resource folder or the file system.
Since noCharsetis 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 noCharsetis 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 managesSoundresources.static Spritesheetsspritesheets()Gets the container that managesSpritesheetresources.static Stringsstrings()Gets a container that managesStringresources.
This instance can be used to access localizable string from a ".properties" file.static Tilesetstilesets()Gets the container that managesTilesetresources.
This implementation uses rawTilesets, to avoid problems withTilesetmethods that aren't in theITilesetinterface.
Method Details
fonts
Gets the container that managesFontresources.- Returns:
- The Font resource container.
- See Also:
Font
sounds
Gets the container that managesSoundresources.- Returns:
- The Sound resource container.
- See Also:
Sound
maps
Gets the container that managesIMapresources.- Returns:
- The IMap resource container.
- See Also:
IMap
tilesets
Gets the container that managesTilesetresources.
This implementation uses rawTilesets, to avoid problems withTilesetmethods that aren't in theITilesetinterface.- Returns:
- The Tileset resource container.
- See Also:
Tileset
strings
Gets a container that managesStringresources.
This instance can be used to access localizable string from a ".properties" file.- Returns:
- The String resource container.
images
Gets the container that managesBufferedImageresources.- Returns:
- The BufferedImage resource container.
- See Also:
BufferedImage
spritesheets
Gets the container that managesSpritesheetresources.- Returns:
- The Spritesheet resource container.
- See Also:
Spritesheet
blueprints
Gets the container that managesBlueprintresources.- Returns:
- The Blueprint resource container.
- See Also:
Blueprint
load
public static void load(java.lang.String gameResourceFile)LoadSpritesheets,TilesetsandMapsfrom 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)LoadSpritesheets,TilesetsandMapsfrom 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 noCharsetis 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 noCharsetis 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)
