libgdx assetmanager纹理加载

时间:2013-10-14 16:04:21

标签: loading libgdx assets

这是我的代码: -

manager = new AssetManager();   

fps =new FPSLogger();

Resolution[] resolutions = {new Resolution(320, 480, ".320480"), new Resolution(480,    800, ".480800"),
new Resolution(480, 856, ".480854")};

 ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);

manager.setLoader(Texture.class, new TextureLoader(resolver));


 manager.load( "images/flash.png" , Texture.class);
 Texture.setAssetManager(manager);
tex =  manager.get("images/flash.png" ,Texture.class);


tex = new Texture(Gdx.files.internal("images/a.png")); 
flsh = new Texture(Gdx.files.internal("images/flash.png"));   
tex2 = new Texture(Gdx.files.internal("images/space.jpg")); 
ear = new Texture(Gdx.files.internal("images/earth.png")); 
newgame=new Texture(Gdx.files.internal("images/shockwave.png")); 

,显示的错误是

 Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Asset not loaded: images/flash.png
at com.badlogic.gdx.assets.AssetManager.get(AssetManager.java:119)
at main.assets.loading(assets.java:53)
at main.game.create(game.java:43)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:132)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:112)

我的图片布局是

/ main(项目名称)/assets/images/a.png

请帮我纠正这个错误

1 个答案:

答案 0 :(得分:5)

在manager.load()和manager.get语句之间使用manager.finishloading()。