Custom exporter for imagesheet sequence data

Hi All,

I couldn’t seem to find anyone who had made one of these so I made one.

https://gist.github.com/03a781663a69763d5605.git

It basically takes the physical folder names (lowest level) and uses those to create the sequence data for the images contained with that folder. So for example if you have the following folder structure in texture packer :-

Animations

|

->Walk

|     |->fred_01.png

|         fred_02.png

|->Run

     |->fred_01.png

         fred_02.png

The exporter will create the following sequence data

SheetInfo.sequenceData =

{

    {   name=Walk,

        frames={  1,  2, },

        time=120 

    }

    {   name=Run,

        frames={  3,  4, }, 

        time=120 

    }

}

Have fun and let me know if you need any help setting it up. I’m also open to suggestions for improvements.

Oh and before I forget the template adds a SheetInfo:getSequenceData() function to retrieve the sequence data for your sprites.

You could add a table which maps name to sequence record ?

The file output by the custom exporter is corona ready and the sequence data is in the correct format for the sprites. The issue is that, once you import sprites into texturepacker. There is no easy way to tell which sprite belongs to which animation, short of manually entering the sequence info into your games lua files.

However, texturepacker does handily prefix each sprite’s name with the folder it belongs to if you import folders or flash animations into the program. Using these it is possible to separate your sprite frames into folders and use the folder names to generate the sequence data in a clean way.

In corona, when you create a sprite from the files you can simply do

local mysprite = display.newSprite( imagesheet, SheetInfo:getSequenceData())

Then when you want to play a particular animation in the sequence you use

mysprite.setSequence(“Walk”)

mysprite:play()

I’m not sure what I would use a table for but, that may be because I’m not understanding what you would need it for.

Have you considered using the Asset management system in Level Director?

Even if you don’t want to use it for level design you can import texturepacker sprite sheets, define animation sequences (as many as you like), specify physics (or import using physics editor) and export it.

If has some helper functions to spawn objects from assets so you never have to worry about coding animations or physics ever again!

There is a tutorial herefor using TP and PE.

It might save you a lot of time.

You could add a table which maps name to sequence record ?

The file output by the custom exporter is corona ready and the sequence data is in the correct format for the sprites. The issue is that, once you import sprites into texturepacker. There is no easy way to tell which sprite belongs to which animation, short of manually entering the sequence info into your games lua files.

However, texturepacker does handily prefix each sprite’s name with the folder it belongs to if you import folders or flash animations into the program. Using these it is possible to separate your sprite frames into folders and use the folder names to generate the sequence data in a clean way.

In corona, when you create a sprite from the files you can simply do

local mysprite = display.newSprite( imagesheet, SheetInfo:getSequenceData())

Then when you want to play a particular animation in the sequence you use

mysprite.setSequence(“Walk”)

mysprite:play()

I’m not sure what I would use a table for but, that may be because I’m not understanding what you would need it for.

Have you considered using the Asset management system in Level Director?

Even if you don’t want to use it for level design you can import texturepacker sprite sheets, define animation sequences (as many as you like), specify physics (or import using physics editor) and export it.

If has some helper functions to spawn objects from assets so you never have to worry about coding animations or physics ever again!

There is a tutorial herefor using TP and PE.

It might save you a lot of time.