In LibGdx, texture image is stored in asset folder and loaded using following code.
Texture texture = new Texture(Gdx.files.internal("image/someImage.jpg"));
I have different texture for different screen resolution, so I want to use Android "res/" directory for saving texture image, which helps to load appropriate image file for appropriate resolution.
Is there any way to load image file from Android "res/" directory?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With