gvlasov
gvlasov

Reputation: 20005

How to pack images into one .png file using TexturePacker2?

Right now I pack images like this:

TexturePacker2.Settings settings = new TexturePacker2.Settings();
settings.flattenPaths = true;
settings.combineSubdirectories = true;
TexturePacker2.process(directory, "pack", atlasName);

But if there are many subdirectories in directory, then for each subdirectory TexturePacker2 creates a separate .png file with suffixes 1, 2, 3 and so on. How can I tell it to pack all images in all subdirectories into one .png file?

Upvotes: 3

Views: 780

Answers (2)

Milan Babuškov
Milan Babuškov

Reputation: 61098

Instead of:

TexturePacker2.process(directory, "pack", atlasName);

you should use:

TexturePacker2.process(settings, directory, "pack", atlasName);

Upvotes: 1

noone
noone

Reputation: 19776

See this link for more information on the TexturePacker2. Putting every subdirectory in an own packfile is the default behaviour, because most of the time you don't want everything in one file, because it would get too big. This way you can organize your textures in groups. One very simple way to avoid this behaviour would be to put everything into one directory and then use the gdx-texturepacker.jar UI to pack it, telling it to use a max width/height of 4096 or maybe even more. The UI does not offer you combineSubdirectories and flattenPaths though.

Thus going the "code way" was the right choice. This offers you all possibilities of the TexturePacker2. It also lets you define the maximum size of one page by setting maxWidth and maxHeight in the TexturePacker2.Settings. If this is high enough, the packer will not need to create several pages.

Upvotes: 1

Related Questions