在libgdx中,AssetManager没有ParticleEffectLoader。所以我为粒子效果编写了一个加载器。但是总是出现错误并说无法加载文件。
任何人都可以帮我解决问题或向我展示一个成功的粒子效果加载器吗?非常感谢!
我的代码:
package com.game.data;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.assets.AssetLoaderParameters;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader;
import com.badlogic.gdx.assets.loaders.FileHandleResolver;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.utils.Array;
public class ParticleEffectLoader extends
AsynchronousAssetLoader<ParticleEffect, AssetLoaderParameters<ParticleEffect>>{
ParticleEffect particleEffect;
public ParticleEffectLoader (FileHandleResolver resolver) {
super(resolver);
if(particleEffect==null){
particleEffect=new ParticleEffect();
}
}
@Override
public void loadAsync(AssetManager manager, String fileName,
AssetLoaderParameters<ParticleEffect> parameter) {
System.out.println("loadAsync");
FileHandle particleFile = resolve(fileName);
particleEffect.loadEmitters(particleFile);
particleEffect.loadEmitterImages(imagesDir);
}
@Override
public ParticleEffect loadSync(AssetManager manager, String fileName,
AssetLoaderParameters<ParticleEffect> parameter) {
System.out.println("loadSync");
return particleEffect;
}
@Override
public Array<AssetDescriptor> getDependencies(String fileName,
AssetLoaderParameters<ParticleEffect> parameter) {
System.out.println("getDependencies");
// FileHandle imagesDir = resolve("res/");
// particleEffect.loadEmitterImages(imagesDir);
return null;
}
}