|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.engine.resource.Resources
public class Resources
The Resources class stores references to various resources which can be
accessed from anywhere in the game. The available types of resources include
BufferedImage Arrays, Sounds, Strings, Integers, and Doubles.
All of the available resources can be loaded on a one-at-a-time basis by
passing in a String filepath or by passing in a File.
Resources also has the ability to load multiple resources at once using an
XML file. This is the main utility of the Resources class.
The vooga.engine.core.Game class calls the Resources.loadResourcesXMLFile method
on the file "resources.xml". Each game should have a resources.xml file located in their
resources package. Further resources can be added later using any load method.
Images are stored as BufferedImage arrays. In the case of images which are
not animations, the array only has one element. Images can be retrieved as
animations, but the animation will only have one frame. Likewise, animations
can be retrieved as images and only the first frame will be retrieved. Images
are loaded using the Game.loadImage() method and supports png, gif, bmp, and
jpg files.
Example files following the standard XML format can be found in the
examples.resources package.
Constructor Summary | |
---|---|
Resources()
|
Method Summary | |
---|---|
static java.awt.image.BufferedImage[] |
getAnimation(java.lang.String key)
Returns the BufferedImage[] associated with the given label. |
static java.lang.String |
getDefaultPath()
Returns the default path of this Resources. |
static double |
getDouble(java.lang.String key)
Returns the double associated with the given double label. |
static Game |
getGame()
Gets the game currently using Resources. |
static java.awt.image.BufferedImage |
getImage(java.lang.String key)
Returns the BufferedImage associated with the given label. |
static int |
getInt(java.lang.String key)
Returns the int associated with the given int label. |
static java.lang.String |
getSound(java.lang.String key)
Returns the String associated with the given Sound label. |
static java.lang.String |
getString(java.lang.String key)
Returns the String associated with the given String label. |
static java.awt.image.BufferedImage[] |
getVisual(java.lang.String key)
Returns the BufferedImage[] associated with the given label. |
static void |
initialize(Game game)
Sets the Game of this Resources and sets the default path to be a blank string. |
static void |
initialize(Game game,
java.lang.String defaultFilePath)
Sets the game of this Resources and sets the default path. |
static void |
loadAnimation(java.lang.String key,
java.io.File[] files)
Puts a new entry into this Resources's imageMap, with a String key and a BufferedImage[] value. |
static void |
loadAnimation(java.lang.String key,
java.lang.String[] filePaths)
Puts a new entry into this Resources's imageMap, with a String key and a BufferedImage[] value. |
static void |
loadDouble(java.lang.String key,
double doubleToLoad)
Puts a new entry into this Resources's doubleMap, with a String key and a double value. |
static void |
loadImage(java.lang.String key,
java.io.File file)
Puts a new entry into this Resources's imageMap, with a String key and a BufferedImage[] value. |
static void |
loadImage(java.lang.String key,
java.lang.String filePath)
Puts a new entry into this Resources's imageMap, with a String key and a BufferedImage[] value. |
static void |
loadInt(java.lang.String key,
int intToLoad)
Puts a new entry into this Resources's integerMap, with a String key and an int value. |
static java.util.ResourceBundle |
loadPreLaunchData(java.lang.String filePath)
Get data to launch the game frame from the main() method of game. |
static void |
loadResourcesXMLFile(java.lang.String resourcesXMLFilepath)
Reads the resources.xml file and initializes the Resources's mappings. |
static void |
loadSound(java.lang.String key,
java.io.File file)
Puts a new entry into this Resources's soundMap, with a String key and a String value. |
static void |
loadSound(java.lang.String key,
java.lang.String filePath)
Puts a new entry into this Resources's soundMap, with a String key and a String value. |
static void |
loadString(java.lang.String key,
java.lang.String stringToLoad)
Puts a new entry into this Resources's stringMap, with a String key and a String value. |
static void |
setDefaultPath(java.lang.String path)
Changes the default path of this Resources. |
static void |
setGame(Game game)
Changes the Game of this Resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Resources()
Method Detail |
---|
public static void initialize(Game game)
public static void initialize(Game game, java.lang.String defaultFilePath)
public static void setGame(Game game)
public static Game getGame()
public static void setDefaultPath(java.lang.String path)
public static java.lang.String getDefaultPath()
public static void loadImage(java.lang.String key, java.io.File file)
public static void loadImage(java.lang.String key, java.lang.String filePath)
public static java.awt.image.BufferedImage getImage(java.lang.String key)
public static void loadAnimation(java.lang.String key, java.io.File[] files)
public static void loadAnimation(java.lang.String key, java.lang.String[] filePaths)
public static java.awt.image.BufferedImage[] getAnimation(java.lang.String key)
public static java.awt.image.BufferedImage[] getVisual(java.lang.String key)
public static void loadSound(java.lang.String key, java.io.File file)
public static void loadSound(java.lang.String key, java.lang.String filePath)
public static java.lang.String getSound(java.lang.String key)
public static void loadString(java.lang.String key, java.lang.String stringToLoad)
public static java.lang.String getString(java.lang.String key)
public static void loadInt(java.lang.String key, int intToLoad)
public static int getInt(java.lang.String key)
public static void loadDouble(java.lang.String key, double doubleToLoad)
public static double getDouble(java.lang.String key)
public static void loadResourcesXMLFile(java.lang.String resourcesXMLFilepath) throws java.io.IOException
java.io.IOException
public static java.util.ResourceBundle loadPreLaunchData(java.lang.String filePath)
filePath
- file path to config.properties
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |