在资源使用文件载入纹理libgdx机器人?纹理、机器人、文件、资源

由网友(唇情爱人)分享简介:在LibGdx,纹理图像存储在资源文件夹,并使用加载以下code。In LibGdx, texture image is stored in asset folder and loaded using following code.Texture texture = new Texture(Gdx.files.in...

在LibGdx,纹理图像存储在资源文件夹,并使用加载以下code。

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

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

我有不同的质地不同的屏幕分辨率,所以我想用Android的RES /目录下保存纹理图像,这有助于加载适当的图像文件进行适当的解决方案。

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.

有没有办法来加载从Android的映像文件RES /目录?

Is there any way to load image file from Android "res/" directory?

推荐答案

您应该看看libgdx的ResolutionFileResolver,并且还用AssetManager(这将减轻对你的一切)。

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

您提供它的分辨率和适当的文件夹使用,然后libgdx自动地选择与最佳匹配的文件夹。

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();

这是做在libgdx的方式,你不应该接触到资源文件夹。

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

阅读全文

相关推荐

最新文章