To render crisp graphics with sprites, I decided to provide a dedicated sprite folder for every resolution size. I have 55 such folders, each folder contains 57 .png
files (which means the total number is 57*55 = 3135 files). I put all 55 folders into a single folder, and run Texture Packer
on that folder. In the output folder, I get 1 pack.atlas
files and 212 packX.png
files (X runs from 1 to 212)
in my code, I create these fields in my Assets
class
private static TextureAtlas atlas;
private static Sprite logo;
// ... total of 57 Sprite fields....
And in the initialize method of the Assets
class, which is called at the beginning of the game:
atlas = new TextureAtlas(Gdx.files.internal("pack.atlas"));
logo = atlas.createSprite(getWidthPath() + "logo"); //getWidthPath() returns the appropriate folder path based on the resolution size. As stated above, there are 55 such folder
//...atlas.createSprite 57 times for 57 fields....
I have done this for a smaller number of folder (3 folder) and the game runs well. However, when I decided to support all 55 resolution folders, the game cannot load on Android and can load on Desktop but really slow at the beginning.
So is it true that the large number of Sprites referenced by the pack.atlas
files caused the hang?
I think if I just run TexturePacker
on each resolution folder, I will get 55 pack.atlas
files (instead of 1) and each pack.atlas
file will now reference to 57 sprites (instead of 3135 files), the game should run fine, but it's too laborious