Java Game Development (Libgdx) TextureAtlas

preview_player
Показать описание
Welcome back everyone to another tutorial with Libgdx. We are covering over the TextureAtlas class for loading and managing textures.

TextureAltas is a common tool that is use in graphics programming for loading/rendering large number of images to our sense. It helps reduce the amount of binding textures, instead using a single large texture.

Рекомендации по теме
Комментарии
Автор

Thank you too much bro, i am from argentina and you content its too useful here. I wish you luck

ianvila
Автор

thank you for this. as a person who is learning OOP and game dev I turned to Java and LibGDX as my first stop. this tutorial is really useful. thanks again :D

starstuff
Автор

This is fantastic.

I just finished a whole situation where I bought a top down rpg tile set that came to me in a single png file with all kinds of dead space and duplicates, so

1. Open the spritesheet image like normal
2. Use the grid and snap to grid for selection tool to select islands of tiles im interested in using
3. Once done, invert the selection, delete the rest
4. Convert the result into a named "Tileset"
5. Export the tileset as an minimized optimized tilesheet image file that ignores empty and duplicate tiles
6. File > Import > Import Sprite Sheet, choose my new tilesheet image, choose 16x16
7. hit "ok" and the whole thing gets imported as individual frames
8. file > export > export as, choose png with a name, hit ok

Out of 1200+ possible exported tiles, I ended up with an optimized 270 individual tile images

Now, what I did at this point in my gdx project, was glob the directory and instantiated a new Sprite for each image, loading each sprite into a global SpriteRegistry. This registry is a simple map array of string key -> sprite value, where the key is the file path. Querying to load a new sprite with that file path first checks the registry and if it’s already loaded and in memory, returns the sprite instance for usage.

So now I can loop across my 4096 int long tile map and just query for each Sprite, set the x y and add it to the one big batch for tile rendering. For 16x16 tiles, the whole thing is damn near instant, and the frame rate is still delicious

But now I’m thinking about this atlas…

KyleHarrisonRedacted
Автор

Awesome to know about this texture packer!

leonidasbrockweld
Автор

what's the difference between textureAtlas and Tiled? Or are they two different things?
great series btw !!

hulium
Автор

Hallo, i have a spritesheet, but have not a *.atlas file, how can i make correct atlasfile?

andrejklester