Вопрос:

libgdx Animation: Is it only possible with a 2d Array or Texture atlas?

java libgdx

144 просмотра

1 ответ

85 Репутация автора

I was looking at this example https://github.com/libgdx/libgdx/wiki/2D-Animation

as well as one on Youtube.

Both feature a program where a texture is loaded (of small regions of equal size), and a 2d array is created to make them into texture regions in an efficient manner.

I'm aware of the TextureAtlas tool to aid in this process. What I want to know is that must I use these two methods?

Can I simply have a array of regular texture regions that don't require a 2D array making them?

Автор: Erick Adam Источник Размещён: 08.11.2017 10:43

Ответы (1)


0 плюса

151 Репутация автора

How would you go about making them regions in the first place? Both of these methods are a convenient way of obtaining a bunch of TextureRegions.

Perhaps you dont quite know why do you use TextureRegions in the first place? When you want to draw something, you need to have an available Texture for it. Making it available is relatively slow process, so you want to minimize it the number of times it happens per frame. Sticking a bunch of small textures into one large one is a way to do just that. The regions are then equivalent to the small textures, or images, you used to make the large one.

TextureAtlas is more advanced method of doing the splitting for images of same size. It simply allows for regions to have different sizes.

Going back to your question, you could have 20 textures, one per frame of animations, but it would be very slow. Especially on mobile devices.

Автор: PiotrJ Размещён: 09.11.2017 10:08
Вопросы из категории :
32x32