Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.87k stars 826 forks source link

AssetManager enqueueWithName doesn't use name argument for TextureAtlas xml #813

Closed jessadacharoen closed 5 years ago

jessadacharoen commented 8 years ago

With the following code, TextureAtlas is added with the name "huds-v0005" instead of "huds". Why does enqueueWithName completely ignore name argument for xml? Is this expected or a bug?

var assets = new AssetManager();
assets.enqueue("https://abcdefg.com/huds-v0005.png");
assets.enqueueWithName("https://abcdefg.com/huds-v0005.xml", "huds");

[AssetManager] Adding texture atlas 'huds-v0005' [AssetManager] Removing texture 'huds-v0005'

PrimaryFeather commented 8 years ago

XML handling is a little special, since all XMLs are processed at the very end, when all other parts of the queue are finished. I just had a look, and here's what's happening:

name = getName(xml.@imagePath.toString());
texture = getTexture(name);
addTextureAtlas(name, new TextureAtlas(texture, xml));

As you can see, the name of the texture is used as the key for both atlas and atlas texture. I must admit I can't remember if there was any special reason for that. Normally, the atlas XML and texture are named the same (e.g. atlas.xml and atlas.png), but I don't see why this would be a must.

My plan is to refactor the complete AssetManager for the 2.1 release — that's a perfect time to look into that again. :-)

PrimaryFeather commented 5 years ago

I forgot to update this – this was fixed with Starling 2.4's new AssetManager.