How to set assets folder of libgdx without creating an android project?

坚强是说给别人听的谎言 提交于 2021-02-16 16:19:39

问题


Is there anyway of doing it?

I can't find any tutorial related to it on google.


回答1:


Libgdx doesn't enforce any particular hierarchy or folder naming conventions for keeping your assets such that Gdx.files.internal("myassets/libgdx.png") would work just fine on Desktop. However, Android projects do have a specific folder in its root named assets. The folder has to be strictly named "assets" as enforced by the Android project [1]. Therefore, it would be a better idea to lay your folder hierarchy the same way in other projects as well so that you won't have to make changes for individual platforms. A much better approach would be to just place your resources in the Android project and link them to other projects. This would allow you to update your resources in only one project and that would be reflected everywhere. This has been explained in detail here.

And as an informative note, start using AssetManager to manage assets for your Libgdx project as it would streamline asset handling to a great degree.




回答2:


You really do not need to do anything. You can use any folder in the Desktop project root. For example:

texture = new Texture(Gdx.files.internal("myfolder/libgdx.png"));


来源:https://stackoverflow.com/questions/20721143/how-to-set-assets-folder-of-libgdx-without-creating-an-android-project

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