1 Reply Latest reply on Jun 7, 2016 10:41 PM by Mylenium

    How would you make a sprite-animation script to speed up this workflow??

    PhoenixRedux

      So, I'm looking to make a preset that allows me to create a dynamic flipbook/spritesheet. It would be a system that could create a grid of duplicate compositions whose time could be controlled independently (linearly, or randomly).

       

      So for example, here's a flipbook/spritesheet with 4 rows (horizontal) and 4 columns (vertical)

       

      http://orig06.deviantart.net/6269/f/2014/072/b/f/round_explosion_sprite_sheet_by_fralexion -d7a1yp2.png

       

      Together, when they make an animation that can be played linearly in this case. The example is some kind of fireball I'm guessing (not my work)

       

      In After Effects, what I typically do is have 1 composition as my "Input" comp (It's where I import any animation I want to eventually turn into a spritesheet, which is how game engines read animation like this)

       

      then I have a 2nd composition, my "Output" comp, which is set to 1 frame in duration, and arranges duplicates of my "Input" comp in however many columns and rows needed.

       

      I "Enable Time Remapping" on all of the frames, then I go through each one and set their time index. "Layer 1 time starts on frame 00:00, Layer 2 frame 00:01, Layer 3 00:02, etc."

       

      I do all of this manually, and it's a bit tedious. I figure there's got to be a way to have that process via scripting.
      any idea how I would go about making this script?

       

        • 1. Re: How would you make a sprite-animation script to speed up this workflow??
          Mylenium Most Valuable Participant

          This isn't even 30 lines of code - one for the time-remapping to freeze the frames, a handful for creating a grid. It's not even worth bothering with scripts, since this can easily be done with expressions and duplicating the layer as often as needed. Here's some simple snippets:

           

          Position:

           

          num_cols=4;

          num_rows=Math.ceil((this_comp.num_layers-1)/num_cols);

           

          place_row=Math.ceil(index/num_cols);

           

          y=place_row*height-height;

          x=(index-1)*width-width*num_cols*(place_row-1);

           

          [x,y]

           

          Time Remapping:

           

          framesToTime(index-1)

           

          Mylenium