public class AssetManager
extends java.lang.Object
implements org.mini2Dx.gdx.utils.Disposable
Loads and stores game assets such as textures, sounds, etc.
The benefit of using the AssetManager vs. fetching assets manually is dependency management, reference counting and caching.
Some assets will be wrapped in a wrapper class to track references to the asset. Calling dispose() on such assets decreases the reference count. Once references to an asset are at zero, it will be disposed of by the AssetManager.
Modifier and Type | Field and Description |
---|---|
static long |
UPDATE_TIMEBOX_MILLIS
The time limit for loading operations per frame.
|
Constructor and Description |
---|
AssetManager(FileHandleResolver fileHandleResolver) |
AssetManager(FileHandleResolver fileHandleResolver,
boolean initDefaultLoaders) |
Modifier and Type | Method and Description |
---|---|
void |
clearAssetLoaders()
Clears all
AssetLoader s so that new ones can be set |
void |
dispose() |
void |
finishLoading() |
<T> T |
get(java.lang.String filePath,
java.lang.Class<T> clazz) |
boolean |
isLoaded(java.lang.String filePath) |
void |
load(AssetDescriptor assetDescriptor) |
<T> void |
load(java.lang.String filePath,
java.lang.Class<T> clazz) |
<T> void |
load(java.lang.String filePath,
java.lang.Class<T> clazz,
AssetProperties assetProperties) |
<T> void |
setAssetLoader(java.lang.Class<T> clazz,
AssetLoader<T> assetLoader)
Sets the
AssetLoader to use for a specific class |
void |
unload(java.lang.String filePath) |
boolean |
update() |
public static long UPDATE_TIMEBOX_MILLIS
public AssetManager(FileHandleResolver fileHandleResolver)
public AssetManager(FileHandleResolver fileHandleResolver, boolean initDefaultLoaders)
public <T> T get(java.lang.String filePath, java.lang.Class<T> clazz)
public boolean isLoaded(java.lang.String filePath)
public <T> void load(java.lang.String filePath, java.lang.Class<T> clazz)
public <T> void load(java.lang.String filePath, java.lang.Class<T> clazz, AssetProperties assetProperties)
public void load(AssetDescriptor assetDescriptor)
public void unload(java.lang.String filePath)
public boolean update()
public void finishLoading()
public <T> void setAssetLoader(java.lang.Class<T> clazz, AssetLoader<T> assetLoader)
AssetLoader
to use for a specific classT
- The class typeclazz
- The class to use the loader forassetLoader
- The AssetLoader
public void clearAssetLoaders()
AssetLoader
s so that new ones can be setpublic void dispose()
dispose
in interface org.mini2Dx.gdx.utils.Disposable