Class ResourceManager


  • public final class ResourceManager
    extends java.lang.Object
    Manages 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 int addFontGenerator​(java.lang.String fontPath)
      loads the font file this doesn't create a font (MAY NOT WORK)
      static int addTexture​(java.lang.String fPath)
      Schedules an asset for loading
      static int addTextureAtlas​(java.lang.String fPath)
      Schedules an asset for loading
      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
      static void cleanUp()
      It is imperative that this is called unless you want memory leeks
      static int createFont​(int font_generator_id, int fontSize)
      Actually creates a font.
      static int createFont​(java.lang.String fontName, int fontSize)
      Actually creates a font.
      static com.badlogic.gdx.graphics.g2d.BitmapFont getFont​(int font_id)  
      static com.badlogic.gdx.graphics.g2d.BitmapFont getFont​(java.lang.String fontName)  
      static int getId​(java.lang.String name)
      only looks for simple assets not specialty ones so largely only textures
      static com.badlogic.gdx.graphics.g2d.Sprite getSprite​(int atlas_id, java.lang.String name)  
      static com.badlogic.gdx.graphics.g2d.Sprite getSprite​(java.lang.String img)
      NEW
      static com.badlogic.gdx.graphics.Texture getTexture​(int id)  
      static com.badlogic.gdx.graphics.Texture getTexture​(java.lang.String fPath)  
      static com.badlogic.gdx.graphics.g2d.TextureAtlas getTextureAtlas​(int id)  
      static com.badlogic.gdx.graphics.g2d.TextureAtlas getTextureAtlas​(java.lang.String fPath)  
      static com.badlogic.gdx.maps.tiled.TiledMap getTileMap​(int id)
      Gets the tile map returns null if not a tile map
      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
      static void Initialize()
      The equivalent to a constructor
      static void loadAssets()
      Actually loads the assets
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceManager

        public ResourceManager()
    • 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 generator
        fontSize - 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 font
        fontSize - 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 atlas
        name - 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