public class AssetManager extends Object implements Disposable
Constructor and Description |
---|
AssetManager()
Creates a new AssetManager with all default loaders.
|
AssetManager(FileHandleResolver resolver)
Creates a new AssetManager with all default loaders.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears and disposes all assets and the preloading queue.
|
<T> boolean |
containsAsset(T asset) |
void |
dispose()
Disposes all assets in the manager and stops all asynchronous loading.
|
void |
finishLoading()
Blocks until all assets are loaded.
|
void |
finishLoadingAsset(String fileName)
Blocks until the specified aseet is loaded.
|
<T> T |
get(AssetDescriptor<T> assetDescriptor) |
<T> T |
get(String fileName) |
<T> T |
get(String fileName,
Class<T> type) |
<T> Array<T> |
getAll(Class<T> type,
Array<T> out) |
<T> String |
getAssetFileName(T asset) |
Array<String> |
getAssetNames() |
Class |
getAssetType(String fileName) |
Array<String> |
getDependencies(String fileName) |
String |
getDiagnostics() |
int |
getLoadedAssets() |
<T> AssetLoader |
getLoader(Class<T> type)
Returns the default loader for the given type
|
<T> AssetLoader |
getLoader(Class<T> type,
String fileName)
Returns the loader for the given type and the specified filename.
|
Logger |
getLogger() |
float |
getProgress() |
int |
getQueuedAssets() |
int |
getReferenceCount(String fileName)
Returns the reference count of an asset.
|
boolean |
isLoaded(String fileName) |
boolean |
isLoaded(String fileName,
Class type) |
void |
load(AssetDescriptor desc)
Adds the given asset to the loading queue of the AssetManager.
|
<T> void |
load(String fileName,
Class<T> type)
Adds the given asset to the loading queue of the AssetManager.
|
<T> void |
load(String fileName,
Class<T> type,
AssetLoaderParameters<T> parameter)
Adds the given asset to the loading queue of the AssetManager.
|
void |
setErrorListener(AssetErrorListener listener)
Sets an
AssetErrorListener to be invoked in case loading an asset failed. |
<T,P extends AssetLoaderParameters<T>> |
setLoader(Class<T> type,
AssetLoader<T,P> loader)
Sets a new
AssetLoader for the given type. |
<T,P extends AssetLoaderParameters<T>> |
setLoader(Class<T> type,
String suffix,
AssetLoader<T,P> loader)
Sets a new
AssetLoader for the given type. |
void |
setLogger(Logger logger) |
void |
setReferenceCount(String fileName,
int refCount)
Sets the reference count of an asset.
|
void |
unload(String fileName)
Removes the asset and all its dependencies, if they are not used by other assets.
|
boolean |
update()
Updates the AssetManager, keeping it loading any assets in the preload queue.
|
boolean |
update(int millis)
Updates the AssetManager continuously for the specified number of milliseconds, yielding the CPU to the loading thread
between updates.
|
public AssetManager()
public AssetManager(FileHandleResolver resolver)
public <T> T get(String fileName)
fileName
- the asset file namepublic <T> T get(String fileName, Class<T> type)
fileName
- the asset file nametype
- the asset typepublic <T> Array<T> getAll(Class<T> type, Array<T> out)
type
- the asset typepublic <T> T get(AssetDescriptor<T> assetDescriptor)
assetDescriptor
- the asset descriptorpublic void unload(String fileName)
fileName
- the file namepublic <T> boolean containsAsset(T asset)
asset
- the assetpublic <T> String getAssetFileName(T asset)
asset
- the assetpublic boolean isLoaded(String fileName)
fileName
- the file name of the assetpublic boolean isLoaded(String fileName, Class type)
fileName
- the file name of the assetpublic <T> AssetLoader getLoader(Class<T> type)
type
- The type of the loader to getpublic <T> AssetLoader getLoader(Class<T> type, String fileName)
type
- The type of the loader to getfileName
- The filename of the asset to get a loader for, or null to get the default loaderpublic <T> void load(String fileName, Class<T> type)
fileName
- the file name (interpretation depends on AssetLoader
)type
- the type of the asset.public <T> void load(String fileName, Class<T> type, AssetLoaderParameters<T> parameter)
fileName
- the file name (interpretation depends on AssetLoader
)type
- the type of the asset.parameter
- parameters for the AssetLoader.public void load(AssetDescriptor desc)
desc
- the AssetDescriptor
public boolean update()
public boolean update(int millis)
public void finishLoading()
public void finishLoadingAsset(String fileName)
fileName
- the file name (interpretation depends on AssetLoader
)public <T,P extends AssetLoaderParameters<T>> void setLoader(Class<T> type, AssetLoader<T,P> loader)
AssetLoader
for the given type.type
- the type of the assetloader
- the loaderpublic <T,P extends AssetLoaderParameters<T>> void setLoader(Class<T> type, String suffix, AssetLoader<T,P> loader)
AssetLoader
for the given type.type
- the type of the assetsuffix
- the suffix the filename must have for this loader to be used or null to specify the default loader.loader
- the loaderpublic int getLoadedAssets()
public int getQueuedAssets()
public float getProgress()
public void setErrorListener(AssetErrorListener listener)
AssetErrorListener
to be invoked in case loading an asset failed.listener
- the listener or nullpublic void dispose()
dispose
in interface Disposable
public void clear()
public Logger getLogger()
Logger
used by the AssetManager
public void setLogger(Logger logger)
public int getReferenceCount(String fileName)
fileName
- public void setReferenceCount(String fileName, int refCount)
fileName
- public String getDiagnostics()
public Array<String> getDependencies(String fileName)
Copyright © 2015. All rights reserved.