如何在andengine中加载大量纹理

发布于 2025-01-05 17:01:07 字数 649 浏览 0 评论 0原文

我尝试按如下方式加载纹理:

private Texture mTexture;
...
    public Textures(final BaseGameActivity activity, final Engine engine) {

        this.mTexture = new Texture(2048, 1024,
                TextureOptions.BILINEAR_PREMULTIPLYALPHA);


        this.mBackgroundTextureRegion = TextureRegionFactory.createFromAsset(
                this.mTexture, activity, "img/back.png", 0, 0);


        this.mSwingBackTextureRegion = TextureRegionFactory.createFromAsset(
                this.mTexture, activity, "img/player.png", 836, 0);
...

我想加载超过 200 个纹理。但是,我当前使用的方法太长。

有没有更快的方法来完成它?

我在 GLES1 工作。

I am trying to load textures as follows:

private Texture mTexture;
...
    public Textures(final BaseGameActivity activity, final Engine engine) {

        this.mTexture = new Texture(2048, 1024,
                TextureOptions.BILINEAR_PREMULTIPLYALPHA);


        this.mBackgroundTextureRegion = TextureRegionFactory.createFromAsset(
                this.mTexture, activity, "img/back.png", 0, 0);


        this.mSwingBackTextureRegion = TextureRegionFactory.createFromAsset(
                this.mTexture, activity, "img/player.png", 836, 0);
...

I want to load more than 200 textures. However, the current method that I am using is too long.

Are there faster methods to complete it?

I am working in GLES1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丶视觉 2025-01-12 17:01:07

最简单的方法是使用Texture Packer,在这里找到

这允许您将多个图像文件添加到一个文件中易于加载精灵表。引擎将此 spritesheet 加载到纹理中并创建一个类,使您可以轻松引用该电子表格中的每个图像。将 200 个纹理区域转换为 1 个纹理包。

我正在使用 GLES2,但不确定 GLES1 的源文件在哪里。逛逛论坛,您应该能够找到如何使用它们。关于它已经有很多讨论了。

The easiest way to do it is with Texture Packer, found here

This allows you to add multiple image files in to one easy to load spritesheet. The engine loads this spritesheet in to a texture and creates a class that lets you easily reference each image from that spreadsheet. Turn 200 TextureRegions in to 1 TexturePack.

I'm using GLES2 and I'm not sure where the source files are for GLES1. Poke around the forums and you should be able to find out how to use them. There has been plenty of talk about it.

葬シ愛 2025-01-12 17:01:07

AndEngine 中内置了一个纹理打包器,可以自动执行此操作。尝试搜索 AndEngine 论坛。
http://www.andengine.org/forums/

There is a texture packer built in AndEngine which does this automagically. Try searching the AndEngine forum.
http://www.andengine.org/forums/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文