有效地打包动画图像/雪碧表的纹理-Libgdx [英] Texture packing animation images/Sprite sheets efficiently-Libgdx

查看:74
本文介绍了有效地打包动画图像/雪碧表的纹理-Libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的LibGdx项目,我拥有的资产包括单个图像和用于动画的精灵表.我知道将所有内容打包到一个图集中很有效.

For my LibGdx project,I have assets including single images and sprite sheets for animation.I know it is efficient to pack everything in to a single atlas.

但是关于精灵表,我该如何打包?打包时是否必须使用一张精灵表或一张精灵表的图像?例如:我有一个名为"snake"的精灵表,它有4帧.我也有蛇框,分别是snake_01,snake_02,snake_03和snake_04.

But when it comes to sprite sheets,how can I pack it?Do I have to use a single sprite sheet or single images of a sprite sheet while packing? Eg:I have a sprite sheet named 'snake' with 4 frames. also I have snake frames in snake_01,snake_02,snake_03 and snake_04.

哪种方法更好?

推荐答案

第二种方法可以减少管理时间.因此,请为动画的每一帧使用单独的文件,例如snake_01.png,snake_02.png等.

The second way is much less time consuming to manage. So use separate files for each frame of animation, like snake_01.png, snake_02.png, etc.

LibGDX TexturePacker会自动将所有这些区域命名为"snake",并为其指定索引号.

LibGDX TexturePacker will automatically name all these regions "snake" and give them an index number.

然后,在加载TextureAtlas之后,您可以拉出整个动画:

Then, after loading the TextureAtlas, you can pull whole animations out:

Array<TextureAtlas.AtlasRegion> snakeRegions = textureAtlas.findRegions("snake");
Animation<TextureRegion> snakeAnimation = new Animation<TextureRegion>(0.1f, snakeRegions);

如果您使用的LibGDX版本低于1.9.5,请省略< TextureRegion> (两次).Animation类在1.9.5版中变得通用.

If you are using a version of LibGDX older than 1.9.5, omit the <TextureRegion> (two times). The Animation class became generic in version 1.9.5.

这篇关于有效地打包动画图像/雪碧表的纹理-Libgdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆