本文整理汇总了Java中com.badlogic.gdx.assets.loaders.AssetLoader类的典型用法代码示例。如果您正苦于以下问题:Java AssetLoader类的具体用法?Java AssetLoader怎么用?Java AssetLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssetLoader类属于com.badlogic.gdx.assets.loaders包,在下文中一共展示了AssetLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAsset
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
private static <T, P extends AssetLoaderParameters<T>> void loadAsset(String filePath, Class<T> type, AssetLoader<T, P> loader) {
if (filePath == null || filePath.trim().isEmpty()) {
Gdx.app.debug(TAG, "Trying to load a " + type.getSimpleName() + " with empty filePath");
return;
}
if (fileResolver.resolve(filePath).exists()) {
assetManager.setLoader(type, loader);
assetManager.load(filePath, type);
assetManager.finishLoading();
Gdx.app.debug(TAG, type.getSimpleName() + " loaded: " + filePath);
} else {
Gdx.app.debug(TAG, type.getSimpleName() + " does not exist: " + filePath);
}
}
示例2: handleImports
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
AssetLoader<T, P> loader, P parameter,
@SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
Element root) throws IOException {
Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
for (Element singleImport : imports) {
String filename = singleImport.get(XMLUtil.XML_FILENAME);
FileHandle file = parentFile.parent().child(filename);
if (!file.exists()) {
throw new GdxRuntimeException("Import " + file.path()
+ " from import for " + parentFile.name()
+ " does not exist.");
}
dependencies.addAll(loader.getDependencies(filename, file, parameter));
}
}
示例3: load
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public <T> T load (String resource, Class<T> type, AssetLoader loader, AssetLoaderParameters<T> params) {
String resolvedPath = new String(resource).replaceAll("\\\\", "/");
boolean exist = assetManager.isLoaded(resolvedPath, type);
T oldAsset = null;
if(exist){
oldAsset = assetManager.get(resolvedPath, type);
for(int i=assetManager.getReferenceCount(resolvedPath); i > 0; --i)
assetManager.unload(resolvedPath);
}
AssetLoader<T, AssetLoaderParameters<T>> currentLoader = assetManager.getLoader(type);
if(loader != null)
assetManager.setLoader(type, loader);
assetManager.load(resource, type, params);
assetManager.finishLoading();
T res = assetManager.get(resolvedPath);
if(currentLoader != null)
assetManager.setLoader(type, currentLoader);
if(exist)
EventManager.get().fire(EVT_ASSET_RELOADED, new Object[]{oldAsset, res});
return res;
}
示例4: prefixFilename
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
private <T> String prefixFilename(Class<T> clazz, String filename) {
AssetLoader loader = getLoader(clazz);
if (loader instanceof AsynchronousAssetLoaderX) {
AsynchronousAssetLoaderX loaderX = (AsynchronousAssetLoaderX) loader;
return loaderX.getFilePrefix() + filename;
}
return filename;
}
示例5: getLoader
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
/** Returns the loader for the given type and the specified filename. If no loader exists for the specific filename, the default
* loader for that type is returned.
* @param type The type of the loader to get
* @param fileName The filename of the asset to get a loader for, or null to get the default loader
* @return The loader capable of loading the type and filename, or null if none exists */
public <T> AssetLoader getLoader (final Class<T> type, final String fileName) {
final ObjectMap<String, AssetLoader> loaders = this.loaders.get(type);
if (loaders == null || loaders.size < 1) return null;
if (fileName == null) return loaders.get("");
AssetLoader result = null;
int l = -1;
for (ObjectMap.Entry<String, AssetLoader> entry : loaders.entries()) {
if (entry.key.length() > l && fileName.endsWith(entry.key)) {
result = entry.value;
l = entry.key.length();
}
}
return result;
}
示例6: setLoader
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
/** Sets a new {@link AssetLoader} for the given type.
* @param type the type of the asset
* @param suffix the suffix the filename must have for this loader to be used or null to specify the default loader.
* @param loader the loader */
public synchronized <T, P extends AssetLoaderParameters<T>> void setLoader (Class<T> type, String suffix,
AssetLoader<T, P> loader) {
if (type == null) throw new IllegalArgumentException("type cannot be null.");
if (loader == null) throw new IllegalArgumentException("loader cannot be null.");
log.debug("Loader set: " + ClassReflection.getSimpleName(type) + " -> " + ClassReflection.getSimpleName(loader.getClass()));
ObjectMap<String, AssetLoader> loaders = this.loaders.get(type);
if (loaders == null) this.loaders.put(type, loaders = new ObjectMap<String, AssetLoader>());
loaders.put(suffix == null ? "" : suffix, loader);
}
示例7: AssetLoadingTask
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public AssetLoadingTask (AssetManager manager, AssetDescriptor assetDesc, AssetLoader loader, AsyncExecutor threadPool) {
this.manager = manager;
this.assetDesc = assetDesc;
this.loader = loader;
this.executor = threadPool;
startTime = manager.log.getLevel() == Logger.DEBUG ? TimeUtils.nanoTime() : 0;
}
示例8: addTask
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
private void addTask(AssetDescriptor paramAssetDescriptor)
{
AssetLoader localAssetLoader = (AssetLoader)this.loaders.get(paramAssetDescriptor.type);
if (localAssetLoader == null)
throw new GdxRuntimeException("No loader for type: " + paramAssetDescriptor.type.getSimpleName());
this.tasks.push(new AssetLoadingTask(this, paramAssetDescriptor, localAssetLoader, this.threadPool));
}
示例9: setLoader
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public <T, P extends AssetLoaderParameters<T>> void setLoader(Class<T> paramClass, AssetLoader<T, P> paramAssetLoader)
{
if (paramClass == null)
try
{
throw new IllegalArgumentException("type cannot be null.");
}
finally
{
}
if (paramAssetLoader == null)
throw new IllegalArgumentException("loader cannot be null.");
this.log.debug("Loader set: " + paramClass.getSimpleName() + " -> " + paramAssetLoader.getClass().getSimpleName());
this.loaders.put(paramClass, paramAssetLoader);
}
示例10: AssetLoadingTask
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public AssetLoadingTask(AssetManager paramAssetManager, AssetDescriptor paramAssetDescriptor, AssetLoader paramAssetLoader, ExecutorService paramExecutorService)
{
this.manager = paramAssetManager;
this.assetDesc = paramAssetDescriptor;
this.loader = paramAssetLoader;
this.threadPool = paramExecutorService;
if (paramAssetManager.log.getLevel() == 3);
for (long l = TimeUtils.nanoTime(); ; l = 0L)
{
this.startTime = l;
return;
}
}
示例11: registerLoader
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
/** @param loader asset loader for the selected type. Will be registered in all managed {@link AssetManager}
* instances.
* @param assetClass class of the loaded asset.
* @see AssetManager#setLoader(Class, AssetLoader)
* @param <Type> type of registered loader. */
public <Type> void registerLoader(final AssetLoader<Type, AssetLoaderParameters<Type>> loader,
final Class<Type> assetClass) {
assetManager.setLoader(assetClass, loader);
eagerAssetManager.setLoader(assetClass, loader);
}
示例12: getLoader
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public AssetLoader<?, ?> getLoader(Class<?> type) {
return manager.getLoader(type);
}
示例13: addTask
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
/** Adds a {@link AssetLoadingTask} to the task stack for the given asset.
* @param assetDesc */
private void addTask (AssetDescriptor assetDesc) {
AssetLoader loader = getLoader(assetDesc.type, assetDesc.fileName);
if (loader == null) throw new GdxRuntimeException("No loader for type: " + ClassReflection.getSimpleName(assetDesc.type));
tasks.push(new AssetLoadingTask(this, assetDesc, loader, executor));
}
示例14: resolve
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
private FileHandle resolve (AssetLoader loader, AssetDescriptor assetDesc) {
if (assetDesc.file == null) assetDesc.file = loader.resolve(assetDesc.fileName);
return assetDesc.file;
}
示例15: load
import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public <T> void load(String paramString, Class<T> paramClass, AssetLoaderParameters<T> paramAssetLoaderParameters)
{
try
{
if ((AssetLoader)this.loaders.get(paramClass) == null)
throw new GdxRuntimeException("No loader for type: " + paramClass.getSimpleName());
}
finally
{
}
int k;
int i;
if (this.loadQueue.size == 0)
{
this.loaded = 0;
this.toLoad = 0;
break label449;
int j = this.loadQueue.size;
k = 0;
if (i < j)
{
AssetDescriptor localAssetDescriptor1 = (AssetDescriptor)this.loadQueue.get(i);
if ((!localAssetDescriptor1.fileName.equals(paramString)) || (localAssetDescriptor1.type.equals(paramClass)))
break label455;
throw new GdxRuntimeException("Asset with name '" + paramString + "' already in preload queue, but has different type (expected: " + paramClass.getSimpleName() + ", found: " + localAssetDescriptor1.type.getSimpleName() + ")");
}
}
while (true)
{
if (k < this.tasks.size())
{
AssetDescriptor localAssetDescriptor3 = ((AssetLoadingTask)this.tasks.get(k)).assetDesc;
if ((localAssetDescriptor3.fileName.equals(paramString)) && (!localAssetDescriptor3.type.equals(paramClass)))
throw new GdxRuntimeException("Asset with name '" + paramString + "' already in task list, but has different type (expected: " + paramClass.getSimpleName() + ", found: " + localAssetDescriptor3.type.getSimpleName() + ")");
}
else
{
Class localClass = (Class)this.assetTypes.get(paramString);
if ((localClass != null) && (!localClass.equals(paramClass)))
throw new GdxRuntimeException("Asset with name '" + paramString + "' already loaded, but has different type (expected: " + paramClass.getSimpleName() + ", found: " + localClass.getSimpleName() + ")");
this.toLoad = (1 + this.toLoad);
AssetDescriptor localAssetDescriptor2 = new AssetDescriptor(paramString, paramClass, paramAssetLoaderParameters);
this.loadQueue.add(localAssetDescriptor2);
this.log.debug("Queued: " + localAssetDescriptor2);
return;
label449: i = 0;
break;
label455: i++;
break;
}
k++;
}
}