vukasin Posted September 18, 2016 Share Posted September 18, 2016 Hi everyone, I'm looking for a way to list animations inside an animation atlas. There seems to be no way to get the data out of AnimationManager (I'm using TypeScript btw). Thx, Vukasin Link to comment Share on other sites More sharing options...
samme Posted September 19, 2016 Share Posted September 19, 2016 Did you use http://phaser.io/docs/2.6.2/Phaser.Animation.html#.generateFrameNames ? Link to comment Share on other sites More sharing options...
vukasin Posted September 19, 2016 Author Share Posted September 19, 2016 Hi Samme, thx for your suggestion. Can you elaborate on this? I don't see how this will help me list the names of the animations already in the atlas? Best, Vukasin Link to comment Share on other sites More sharing options...
lewster32 Posted September 19, 2016 Share Posted September 19, 2016 The animation names will be in the .json file associated with the atlas. Generally speaking, if you've generated the atlas yourself you will know the animation names available. Link to comment Share on other sites More sharing options...
vukasin Posted September 19, 2016 Author Share Posted September 19, 2016 Hi Lewseter, This is true. I was hoping that I could automate the loading of a sprite from atlas->phaser to eliminate the need for hardcoding frame id's etc. I'll just do it by loading the data myself and post the method here once i'm done. Best, Vukasin Link to comment Share on other sites More sharing options...
drhayes Posted September 19, 2016 Share Posted September 19, 2016 Check the cache once the atlas is loaded. According to the docs you can say "game.cache.getImage('key');" and you'll get your atlas back. Link to comment Share on other sites More sharing options...
vukasin Posted September 19, 2016 Author Share Posted September 19, 2016 Hi drhayes, this is true. However, what I get back is an img HTML node. Not the atlas data. If you look at the AnimationParser you'll see that the information from the atlas is discarded after loading the frames :-( Best, Vukasin Link to comment Share on other sites More sharing options...
samme Posted September 19, 2016 Share Posted September 19, 2016 Do you mean an atlas like http://examples.phaser.io/assets/sprites/seacreatures_json.json ? I don't think the atlas holds animation names per se, just frame names. I think you can get the frame names with http://phaser.io/docs/2.6.2/Phaser.Cache.html#getFrameData . Link to comment Share on other sites More sharing options...
vukasin Posted September 19, 2016 Author Share Posted September 19, 2016 Hi samme, true, some apps don't store animation data in atlas. Some however, do. One example is Aseprite. It stores the animation data in metadata. And that's the crux of the whole thing. That part of the JSON is thrown away by the parser. But as @lewster32 pointed out, I can still load the JSON again and extract the information. I was just hoping to get it from Phaser. I guess I should change the way I load and first load the JSON and pass the data to Phaser afterwards via jsonData. Best, Vukasin Link to comment Share on other sites More sharing options...
drhayes Posted September 19, 2016 Share Posted September 19, 2016 Ah, shoot! My misunderstanding -- I thought Cache.getImage would give you back JSON for some reason, which, DUH, of course not. You might be better off using loader.json to load it, find whatever information you need out of it, then add it directly to the cache as a texture atlas. Or store it in some registry where you can pull the frame names out later. vukasin 1 Link to comment Share on other sites More sharing options...
vukasin Posted September 19, 2016 Author Share Posted September 19, 2016 yup, that's exactly what i'm going to do ;-) Link to comment Share on other sites More sharing options...
Recommended Posts