Artenus 2D Framework
Artenus Reference
Serves as the central point to manipulate Texture objects in the framework. It provides methods to create, load and unload textures and it will make sure that textures that are used are valid. This class handles the "loading" of graphical assets when your game starts up, or before every scene with local assets. But this procedure is effectively hidden from the developer and you do not need to worry about creating your own loading screens and texture handling.
public final class TextureManager

Constructor Summary

Modifier and TypeConstructor and Description
public TextureManager()

Method Summary

Modifier and TypeMethod and Description
public static voidadd(int... textureSet)
Declares textures for the current context.
public static voidaddLocal(int... textureSet)
Declares local textures for a scene.
public static TextureManager.StatesgetCurrentState()
Gets the current state of the texture manager.
public static FontgetFont(int resourceId)
Gets the Font associated with the given resource identifier.
public static intgetLoadedCount()
Gets the number of textures that are loaded and ready to be displayed.
public static TexturegetLoadingTexture()
Gets the texture displayed in the loading screen.
public static intgetLoadingTextureHeight()
Gets the height of the texture displayed in the loading screen.
public static intgetLoadingTextureWidth()
Gets the width of the texture displayed in the loading screen.
public static ShaderProgramgetShaderProgram()
Gets the shader program used to draw textured entities in the framework.
public static TexturegetTexture(int resourceId)
Gets the Texture associated with the given resource identifier.
public static intgetTextureCount()
Gets the number of textures currently managed by the texture manager.
public static floatgetTextureScalingFactor()
Retrieves the texture scaling factor.
public static voidloadTextures()
Loads all the textures.
public static voidsetLoadingTexture(int resId)
Sets the texture displayed in the loading screen.
public static voidsetTextureScalingFactor(float factor)
Called by the stage to set the scaling factor.
public static voidunloadAll()
Unloads all textures and clears the list.
public static voidunloadLocal()
Unloads local textures previously loaded using addLocal(int...).
public static voidunloadTextures()
Unloads the textures, but keeps the bookkeeping information.

Methods inherited from java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

TextureManager
public  TextureManager()

Method Detail

add
public static void add(
    int... textureSet
)
Declares textures for the current context. This method is one of the building blocks of the "loading" procedure in the game. It should be called from the onLoadStage(Stage) method of StageManager. All textures used widely throughout the game should be introduced using this method. Textures loaded using this method will always be available. Be careful not to load a lot of textures using this method and consider memory constraints on your target devices. If you have textures that are only used in some scenes, consider using local loading of those textures instead of globally loading them using this method.
Parameters:
textureSetThe set of resource identifiers for the textures and fonts to load
See Also:
addLocal
public static void addLocal(
    int... textureSet
)
Declares local textures for a scene. This method should be called within the onLocalLoad() method of the Scene class.
Parameters:
textureSetThe set of resource identifier for the textures to load
See Also:
getCurrentState
public static TextureManager.States getCurrentState()
Gets the current state of the texture manager.
Returns:
The state
getFont
public static Font getFont(
    int resourceId
)
Gets the Font associated with the given resource identifier. If the given resource identifier does not represent a font this method might throw an exception.
Parameters:
resourceIdThe resource identifier
Returns:
The Font corresponding to the resource identifier or null if the font has not been set up in the texture manager
See Also:
getLoadedCount
public static int getLoadedCount()
Gets the number of textures that are loaded and ready to be displayed.
Returns:
Number of textures
getLoadingTexture
public static Texture getLoadingTexture()
Gets the texture displayed in the loading screen. The framework has a default loading texture, but it can also be modified for each game.
Returns:
The loading texture
getLoadingTextureHeight
public static int getLoadingTextureHeight()
Gets the height of the texture displayed in the loading screen.
Returns:
The height of the loading texture
getLoadingTextureWidth
public static int getLoadingTextureWidth()
Gets the width of the texture displayed in the loading screen.
Returns:
The width of the loading texture
getShaderProgram
public static ShaderProgram getShaderProgram()
Gets the shader program used to draw textured entities in the framework.
Returns:
The shader program
getTexture
public static Texture getTexture(
    int resourceId
)
Gets the Texture associated with the given resource identifier.
Parameters:
resourceIdThe resource identifier
Returns:
The Texture corresponding to the resource identifier or null if the texture has not been set up in the texture manager
See Also:
getTextureCount
public static int getTextureCount()
Gets the number of textures currently managed by the texture manager.
Returns:
Number of textures
getTextureScalingFactor
public static float getTextureScalingFactor()
Retrieves the texture scaling factor. Normally the stage is assumed to have the smallest dimension of 600. The smallest dimension means the the width in portrait mode and height in landscape mode. If the real dimensions is larger that this, textures are scaled to maintain this perception from the developer's point of view. This method yields the scaling factor used.
Returns:
The texture scaling factor.
loadTextures
public static void loadTextures()
Loads all the textures. This is part of the "loading" process and normally the loading screen is displayed before this method starts. Manual use of this method is not recommended.
setLoadingTexture
public static void setLoadingTexture(
    int resId
)
Sets the texture displayed in the loading screen. It is recommended that you don't call this method directly and use Stage attributes to set the loading texture.
Parameters:
resIdThe resource identifier for the loading texture
See Also:
setTextureScalingFactor
public static void setTextureScalingFactor(
    float factor
)
Called by the stage to set the scaling factor. You should not call this method manually.
Parameters:
factorTexture scaling factor.
See Also:
unloadAll
public static void unloadAll()
Unloads all textures and clears the list. After calling this method, add(int...) needs to be called again to add a new set of textures.
unloadLocal
public static void unloadLocal()
Unloads local textures previously loaded using addLocal(int...). This method is called internally and you do not need to manually handle the unloading of textures.
unloadTextures
public static void unloadTextures()
Unloads the textures, but keeps the bookkeeping information. This method is called to temporarily free memory allocated to texture when the application is paused. This method is called internally and manual use is not recommended.