Multiple Texture Atlases in Skin constructor
See original GitHub issueIssue 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:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Create an empty skin with
new Skin()
and populate it with multiple atlases by callingaddRegions(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.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.