Loading texture in libgdx android using file in res?

后端 未结 1 604
青春惊慌失措
青春惊慌失措 2021-02-10 07:12

In LibGdx, texture image is stored in asset folder and loaded using following code.

Texture texture = new Texture(Gdx.files.internal(\"image/someImage.jpg\"));
<         


        
相关标签:
1条回答
  • 2021-02-10 07:34

    You should look into libgdx's ResolutionFileResolver, and also use AssetManager (it will ease everything for you).

    You supply it resolutions and the proper folder to use, and then libgdx automagically selects the folder with the best match.

    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 = new AssetManager();
    

    This is the way to do it in libgdx, you shouldn't touch the res folder.

    0 讨论(0)
提交回复
热议问题