Simple Sprite Animation
I wanted to have a system that allowed me to set timings of sprite animations (flip-books, basically) at a frame by frame level. This lead to the creation of a simple DSL for defining a set of states, with frame timings. It has some basic commands for transitioning between states, looping, including ping-pong, and waiting for explicit “next steps”. Individual frames can also define the “frame index” explicity, and have arbitrary “events” which are broadcast. Here is a small example:
Idle: 5, 5, _loop
Jump: 2|vfxJump, 5, 5, _wait
Walk: 8|afxStep, 8, 8|afxStep, 8, _loop
The _loop and _wait do what you would expect. The 2|vfxJump is an example of a duration (how many “ticks” of the animation system before that frame is complete, and we move on), and then an event name which is broadcast. So we display the 1st frame of the Jump state for two ticks, and broadcast the event “vfxJump” (via a public event System.Action<string>).