当前位置: 首页>>代码示例>>Java>>正文


Java AssetLoader类代码示例

本文整理汇总了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);
}
   }
 
开发者ID:Quillraven,项目名称:Quilly-s-Castle,代码行数:17,代码来源:Utils.java

示例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));
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:LoaderUtil.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:FlameMain.java

示例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;
}
 
开发者ID:GameDevWeek,项目名称:CodeBase,代码行数:9,代码来源:AssetManagerX.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:AssetManager.java

示例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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:14,代码来源:AssetManager.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:AssetLoadingTask.java

示例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));
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:8,代码来源:AssetManager.java

示例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);
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:16,代码来源:AssetManager.java

示例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;
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:14,代码来源:AssetLoadingTask.java

示例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);
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:11,代码来源:AssetService.java

示例12: getLoader

import com.badlogic.gdx.assets.loaders.AssetLoader; //导入依赖的package包/类
public AssetLoader<?, ?> getLoader(Class<?> type) {
	return manager.getLoader(type);
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:4,代码来源:Assets.java

示例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));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:8,代码来源:AssetManager.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:5,代码来源:AssetLoadingTask.java

示例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++;
  }
}
 
开发者ID:isnuryusuf,项目名称:ingress-indonesia-dev,代码行数:54,代码来源:AssetManager.java


注:本文中的com.badlogic.gdx.assets.loaders.AssetLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。