我有两个纹理需要管理。
一种位于 Gdx.files.internal
中,另一种位于 Gdx.files.local
中。
但 API 似乎限制我只能管理其中之一,而不是同时管理两者。
manager = new AssetManager( - takes only one resolver - `);
manager.setLoader(TextureAtlas.class, new TextureAtlasLoader( - takes only one resolver - ));
而这个只需要一名经理:
Texture.setAssetManager(manager);
有没有办法管理两个解析器? 或者为两个位置构建一个解析器?
谢谢!
最佳答案
您可以编写一个自定义的FileHandleResolver
,它首先检查文件是否存在于第一个位置,如果不存在,则检查第二个位置。
也许像这样:
class MyFileHandleResolver implements FileHandleResolver {
public FileHandle resolve(String fileName) {
FileHandle localHandle = Gdx.files.local(fileName);
if (localHandle.exists())
return localHandle;
else
return Gdx.files.internal(fileName);
}
}
关于java - libgdx - AssetsManager - 管理多个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16262385/