java - What is the difference between textureregion and atlasregion in LibGdx? -


i wondered difference is. , can diference between texture , textureatlas.

greetz luc

when load texture in game doing texture t = new texture("");, load texture in gpu.

textureregion, takes area texture according dimension provide, advantage of having don't have load textures again , again , bigger advantage don't have load each , every texture on gpu can directly loading 1 big texture , extracting sub regions(textureregions) it.

now because want use textureregions, hard know dimensions of each , every sub image load them texture sheet. we pack textures bigger texture using texturepacker(an application) creates .pack file. pack every texture 1 image , create .pack file. when load .pack file, loaded using textureatlas class example imagine pokemon pack file has pokemons it.

 textureatlas  pokemonfrontatlas = new textureatlas(gdx.files.internal("pokemon//pokemon.pack")); 

now imagine packed 100 files using texture packer , want load image(texture) has file name "somepokemon".

now particular textureregion it,

pokemonfrontatlas.findregion("somepokemon") 

findregion(string name) returns textureregion textureatlas.

so sum up, major difference is, textureregion region texture whereas textureatlas collection of textureregions.

edit

a textureatlas class contains collection of atlasregion class extends textureregion class.

see javadocs more details textureatlas


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -