LibGdx TmxMapLoader加载外部文件

时间:2014-08-26 11:42:38

标签: java android libgdx

我尝试从sdcard加载TiledMap。 在TmxMapLoader.java中说......

 * Loads the {@link TiledMap} from the given file. The file is resolved via the {@link FileHandleResolver} set in the
 * constructor of this class. By default it will resolve to an internal file.

那么,如何将默认值更改为外部?

谢谢

1 个答案:

答案 0 :(得分:1)

您可以在构造函数中提供自定义FileHandleResolver:

TiledMap map = new TmxMapLoader(new ExternalFileHandleResolver()).load("level1.tmx");

有关FileHandleResolver的更多信息:http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/FileHandleResolver.html