LibGdx TmxMapLoader load external files

倖福魔咒の 提交于 2020-01-25 16:43:49

问题


I tried to load an TiledMap from the sdcard. In TmxMapLoader.java is says...

 * 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.

So, how can I change the default value to external?

Thank you


回答1:


You can provide custom FileHandleResolver in constructor:

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

More info about FileHandleResolver: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/FileHandleResolver.html



来源:https://stackoverflow.com/questions/25505014/libgdx-tmxmaploader-load-external-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!