Package com.mygdx.game.Managers
Class ResourceManager
- java.lang.Object
-
- com.mygdx.game.Managers.ResourceManager
-
public final class ResourceManager extends java.lang.ObjectManages all assets and disposes of them when appropriate
-
-
Constructor Summary
Constructors Constructor Description ResourceManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intaddFontGenerator(java.lang.String fontPath)loads the font file this doesn't create a font (MAY NOT WORK)static intaddTexture(java.lang.String fPath)Schedules an asset for loadingstatic intaddTextureAtlas(java.lang.String fPath)Schedules an asset for loadingstatic intaddTileMap(java.lang.String fPath)Prefaces name with |TM| followed by the internal index of the tilemap however this isn't required to access this assetstatic voidcleanUp()It is imperative that this is called unless you want memory leeksstatic intcreateFont(int font_generator_id, int fontSize)Actually creates a font.static intcreateFont(java.lang.String fontName, int fontSize)Actually creates a font.static com.badlogic.gdx.graphics.g2d.BitmapFontgetFont(int font_id)static com.badlogic.gdx.graphics.g2d.BitmapFontgetFont(java.lang.String fontName)static intgetId(java.lang.String name)only looks for simple assets not specialty ones so largely only texturesstatic com.badlogic.gdx.graphics.g2d.SpritegetSprite(int atlas_id, java.lang.String name)static com.badlogic.gdx.graphics.g2d.SpritegetSprite(java.lang.String img)NEWstatic com.badlogic.gdx.graphics.TexturegetTexture(int id)static com.badlogic.gdx.graphics.TexturegetTexture(java.lang.String fPath)static com.badlogic.gdx.graphics.g2d.TextureAtlasgetTextureAtlas(int id)static com.badlogic.gdx.graphics.g2d.TextureAtlasgetTextureAtlas(java.lang.String fPath)static com.badlogic.gdx.maps.tiled.TiledMapgetTileMap(int id)Gets the tile map returns null if not a tile mapstatic com.badlogic.gdx.maps.tiled.TiledMapgetTileMap(java.lang.String fPath)Looks for fPath in ids then determines if it is a tile map and returns the corresponding mapstatic voidInitialize()The equivalent to a constructorstatic voidloadAssets()Actually loads the assets
-
-
-
Method Detail
-
Initialize
public static void Initialize()
The equivalent to a constructor
-
addTexture
public static int addTexture(java.lang.String fPath)
Schedules an asset for loading- Parameters:
fPath- the file path of the asset- Returns:
- returns the id of the asset can be used in place of the name;
-
addTextureAtlas
public static int addTextureAtlas(java.lang.String fPath)
Schedules an asset for loading- Parameters:
fPath- the file path of the asset- Returns:
- returns the id of the asset can be used in place of the name;
-
addTileMap
public static int addTileMap(java.lang.String fPath)
Prefaces name with |TM| followed by the internal index of the tilemap however this isn't required to access this asset- Parameters:
fPath- the file location of the asset- Returns:
- id of the asset
-
addFontGenerator
public static int addFontGenerator(java.lang.String fontPath)
loads the font file this doesn't create a font (MAY NOT WORK)- Parameters:
fontPath- the path of the font file- Returns:
- the id of the font generator
-
createFont
public static int createFont(int font_generator_id, int fontSize)Actually creates a font. Can be created after the final load request (MAY NOT WORK)- Parameters:
font_generator_id- the id of the font generatorfontSize- the size of the desired font this can't be changed later (would have load another font)- Returns:
- id of the font -1 not found
-
createFont
public static int createFont(java.lang.String fontName, int fontSize)Actually creates a font. Can be created after the final load request (MAY NOT WORK)- Parameters:
fontName- the file name of the fontfontSize- the size of the desired font this can't be changed later (would have load another font)- Returns:
- id of the font -1 if not found
-
loadAssets
public static void loadAssets()
Actually loads the assets
-
getTexture
public static com.badlogic.gdx.graphics.Texture getTexture(java.lang.String fPath)
-
getTextureAtlas
public static com.badlogic.gdx.graphics.g2d.TextureAtlas getTextureAtlas(java.lang.String fPath)
-
getTileMap
public static com.badlogic.gdx.maps.tiled.TiledMap getTileMap(java.lang.String fPath)
Looks for fPath in ids then determines if it is a tile map and returns the corresponding map- Parameters:
fPath- the fPath to the asset- Returns:
- The asset if found or null
-
getTexture
public static com.badlogic.gdx.graphics.Texture getTexture(int id)
-
getTextureAtlas
public static com.badlogic.gdx.graphics.g2d.TextureAtlas getTextureAtlas(int id)
-
getSprite
public static com.badlogic.gdx.graphics.g2d.Sprite getSprite(int atlas_id, java.lang.String name)- Parameters:
atlas_id- the id of the source texture atlasname- the name of the texture- Returns:
- the found Sprite in the given atlas
-
getSprite
public static com.badlogic.gdx.graphics.g2d.Sprite getSprite(java.lang.String img)
NEW- Parameters:
img- image name- Returns:
- sprite
-
getTileMap
public static com.badlogic.gdx.maps.tiled.TiledMap getTileMap(int id)
Gets the tile map returns null if not a tile map- Parameters:
id- the id of the tile map- Returns:
- the tile map
-
getId
public static int getId(java.lang.String name)
only looks for simple assets not specialty ones so largely only textures- Parameters:
name- the desired asset name- Returns:
- the id of the asset found if found
-
getFont
public static com.badlogic.gdx.graphics.g2d.BitmapFont getFont(int font_id)
-
getFont
public static com.badlogic.gdx.graphics.g2d.BitmapFont getFont(java.lang.String fontName)
-
cleanUp
public static void cleanUp()
It is imperative that this is called unless you want memory leeks
-
-