LDEngine icon indicating copy to clipboard operation
LDEngine copied to clipboard

Extend SpriteAnim to support TexturePacker data files.

Open 3vi1 opened this issue 10 years ago • 1 comments

I'm not sure if you guys use TexturePacker (http://www.codeandweb.com/texturepacker) or not, but I think it's awesome. So, I thought I'd add this as a placeholder for some code I intend to submit.

This will enable us more easily manage/load large group of sprites at once (like maybe all the sprites used in a particular level), and it eliminates the need to calculate or hard-code any source offsets/widths in any the main game code. Sprites can really be jammed together to make maximum use of memory.

I already have this functionality in the demo project I was writing. I save my multi-frame sprites out of Aseprite as a .png and it automatically throws a number on the end of the filename for each separate frame it writes. In my code, after loading the SpriteSheet, my animation class just gets the source rectangle and info for any individual frame with FrameItem item = spriteSheet.Item("sprite_name#") (where # is the current frame number).

I'd commit it immediately, but I wrote my existing SpriteSheet class to use TilePacker data exported in JSON format. I think I should rewrite it to use Generic XML for consistency with the Tmx files, plus to eliminate the thirdparty dependency my current code has on JSON.net (or some other JSON lib I used to more quickly throw it together).

3vi1 avatar May 07 '14 21:05 3vi1