Animation is a key to any quality game. The workflow you choose, from design to screen, will not only impact the quality of your end-product, but also the fun you have during development.
I am happy to share a workflow that goes straight from Flash to sprite sheets, and a library for Haxe and NME that takes those sprite sheets and easily places them on-screen. I am very excited about using this process more.
I have posted the sprite sheet engine I am using on haxelib
haxelib install spritesheet
Inside of the directory, I have included an export directory for use with SpriteLoq. You can either find “nme.meta” in your lib directory after installing “spritesheet”, or you can get a copy of it here. You will want to copy this file to “enabled_export_templates”, where SpriteLoq has been installed on your system. For example, on mine it was at “C:\Program Files (x86)\SpriteLoq”. If you want, you can also remove “corona.meta” from that same directory.
After exporting a sprite sheet from SpriteLoq, you can also use the “Import” command in SpriteLoq to bring it back again. Just import the XML file that is generated from SpriteLoq, and it will repopulate your settings. This is useful if you need to go back and revise an old export, or need to regenerate your sprite sheet after SpriteLoq has been closed.
Once you have SpriteLoq and the “spritesheet” library installed, you can try the sample project. Included in the directory is an FLA with a single animation, the resulting export from SpriteLoq and source code to load, display and animate the shape.
The sprite sheet engine uses a “SpriteSheet” class with data for the image, frames and behaviors, which you can access through an “AnimatedSprite” class. Sprite sheets can be shared among multiple animated sprites, which all have their own timeline. Animated sprites do not have their own timers, so in a frame loop somewhere, you need to update sprites with the “delta time” for their animations.
I decided not to make the animations occur based on absolute real time, because you may decide to freeze objects or pause the entire application. In this way, you can create your own timing offsets to allow for a delta time that creates the animation you are looking for. If objects were based on absolute real time, it would be impossible to pause and resume their animations appropriately.
You do not need to use SpriteLoq in order to take advantage of the sprite sheet engine, but an importer is provided to automate the process from SpriteLoq to your completed SpriteSheet instance in Haxe. The engine is compatible with NME, so you can publish your application to Flash or to C++ targets like Windows, Mac, Linux, iOS, webOS or Android.
If you like screencasts, or want to see this for your self, I’ve posted a short screencast that goes from an animation created in Flash, to SpriteLoq to generate the sprite sheets, to Haxe where the sprite sheet engine makes it all come back to life again.
Check it out here and let me know what you think!