It appears from the source that the regions added to the Skin
are stored in an Array
and found via string comparison in 0.9.8 just as they are in the TextureAtlas
. The lookup times will be similar.
Libgdx - Using TextureAtlas with Skin. Memory Consideration?
-
29-06-2022 - |
문제
I am using TextureAtlas
to load my assets for a game in Libgdx. I know that TextureAtlas's method findRegion
is expensive, memory wise, so it should be loaded once and stored.
I was just going through the Skin
class where I encountered this example:
TextureAtlas atlas = ...
Skin skin = new Skin();
skin.addRegions(atlas);
...
TextureRegion hero = skin.get("hero", TextureRegion.class);
This means that I can get my textures using Skin as well. My question is, how does the Skin class loads these assets. Does it loads everything upon skin.addRegions(atlas);
? Or does the skin.get("hero", TextureRegion.class);
loads it from the TextureAtlas on every call, making it as expensive as the atlas.findRegion("hero")
call?
I am looking to load all my assets from TextureAtlas at the start of game. So I was thinking that I could do a simple load in skin and then use my assets from there?
해결책