question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple Texture Atlases in Skin constructor

See original GitHub issue

Issue details

I’m suggesting that Scene2D have support for multiple Texture Atlases in Skin, here’s how I think it’ll work:

Skin.java Before:

/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas"
 * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is
 * automatically disposed when the skin is disposed. */
public Skin (FileHandle skinFile) {
    FileHandle atlasFile = skinFile.sibling(skinFile.nameWithoutExtension() + ".atlas");
    if (atlasFile.exists()) {
        atlas = new TextureAtlas(atlasFile);
        addRegions(atlas);
    }

    load(skinFile);
}

[...]

/** Creates a skin containing the resources in the specified skin JSON file and the texture regions from the specified atlas.
 * The atlas is automatically disposed when the skin is disposed. */
public Skin (FileHandle skinFile, TextureAtlas atlas) {
    this.atlas = atlas;
    addRegions(atlas);
    load(skinFile);
}   

After:

  • Note I haven’t tested this, I’m on the edge that it works…
/** Creates a skin containing the resources in the specified skin JSON file. If a file in the same directory with a ".atlas"
 * extension exists, it is loaded as a {@link TextureAtlas} and the texture regions added to the skin. The atlas is
 * automatically disposed when the skin is disposed. */
public Skin (FileHandle skinFile) {
    for(FileHandle sibling : skinFile.parent().list())
            if(sibling.extension().toLowerCase().equals("atlas")) 
                addRegions(new TextureAtlas(sibling));
    load(skinFile);
}

[...]

/** Creates a skin containing the resources in the specified skin JSON file and the texture regions from the specified atlas.
 * The atlas is automatically disposed when the skin is disposed. */
public Skin (FileHandle skinFile, TextureAtlas ... atlases) {
    this.atlas = atlas;
    for(TextureAtlas atlas : atlases) addRegions(atlas);
    load(skinFile);
}   

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
NathanSweetcommented, Aug 7, 2016

Create an empty skin with new Skin() and populate it with multiple atlases by calling addRegions(TextureAtlas) multiple times. The only difference is you will need to dispose the atlases yourself, whereas when using the constructor the skin owns the atlas and disposes it with the skin.

1reaction
cypherdarecommented, Aug 1, 2016

Maybe instead of cluttering Skin, add the ability to merge TextureAtlases. It could have a merge method that takes a parameter for how to handle name collisions (omit the regions vs. modify their names).

This potentially is more versatile. I didn’t understand the reason for needing multiple atlases at first, but I can think of one use case. If you have some parts of your skin that are resolution independent, while you have some that need multiple sizes, it might be handy to put them in separate atlases so you never have to load anything whose size is unneeded on the installed device. However, this could cause a lot of batch flushing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Do I have to always have an .atlas file when making a skin?
the Skin has many various contructors like: Skin() Skin(FileHandle skinFile) Skin(FileHandle skinFile, TextureAtlas atlas) Skin(TextureAtlas ...
Read more >
Separated atlas for each skin - Spine
You can run the texture packer separately from exporting JSON/binary, once for each atlas. You can use the command line to pack multiple...
Read more >
Resolving different Sprite Atlas scenarios - Unity - Manual
Both Sprite Atlases have different Texture output settings in this example. Result: The Project's published build includes both Sprite Atlases. Unity randomly ...
Read more >
How would you declare a Texture object in the libgdx skin json ...
I have a texture atlas that is linked to my skin.json file. The atlas contains a region named "game-title". I would like to...
Read more >
Skin Builder Tutorial
Texture files location Runtime\textures\DSZV\SkinBuilder ... Skin Builder works by blending in different skin maps and combining them with an underlying ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found