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 Type Method Description static Blueprints
blueprints()
Gets the container that managesBlueprint
resources.static void
clearAll()
Clears the all resource containers by removing previously loaded resources.static Fonts
fonts()
Gets the container that managesFont
resources.static java.io.InputStream
get(java.lang.String file)
Gets the specified file as InputStream from either a resource folder or the file system.static java.io.InputStream
get(java.net.URL file)
Gets the specified file as InputStream from either a resource folder or the file system.static java.net.URL
getLocation(java.lang.String name)
static Images
images()
Gets the container that managesBufferedImage
resources.static void
load(java.lang.String gameResourceFile)
LoadSpritesheets
,Tilesets
andMaps
from a game resource file created with the utiLITI editor.static void
load(java.net.URL gameResourceFile)
LoadSpritesheets
,Tilesets
andMaps
from a game resource file created with the utiLITI editor.static Maps
maps()
Gets the container that managesIMap
resources.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 noCharset
is specified with this overload, the implementation uses UTF-8 by default.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.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 noCharset
is specified with this overload, the implementation uses UTF-8 by default.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.static Sounds
sounds()
Gets the container that managesSound
resources.static Spritesheets
spritesheets()
Gets the container that managesSpritesheet
resources.static Strings
strings()
Gets a container that managesString
resources.
This instance can be used to access localizable string from a ".properties" file.static Tilesets
tilesets()
Gets the container that managesTileset
resources.
This implementation uses rawTileset
s, to avoid problems withTileset
methods that aren't in theITileset
interface.
Method Details
fonts
Gets the container that managesFont
resources.- Returns:
- The Font resource container.
- See Also:
Font
sounds
Gets the container that managesSound
resources.- Returns:
- The Sound resource container.
- See Also:
Sound
maps
Gets the container that managesIMap
resources.- Returns:
- The IMap resource container.
- See Also:
IMap
tilesets
Gets the container that managesTileset
resources.
This implementation uses rawTileset
s, to avoid problems withTileset
methods that aren't in theITileset
interface.- Returns:
- The Tileset resource container.
- See Also:
Tileset
strings
Gets a container that managesString
resources.
This instance can be used to access localizable string from a ".properties" file.- Returns:
- The String resource container.
images
Gets the container that managesBufferedImage
resources.- Returns:
- The BufferedImage resource container.
- See Also:
BufferedImage
spritesheets
Gets the container that managesSpritesheet
resources.- Returns:
- The Spritesheet resource container.
- See Also:
Spritesheet
blueprints
Gets the container that managesBlueprint
resources.- Returns:
- The Blueprint resource container.
- See Also:
Blueprint
load
public static void load(java.lang.String gameResourceFile)LoadSpritesheets
,Tilesets
andMaps
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)LoadSpritesheets
,Tilesets
andMaps
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 noCharset
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 noCharset
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)