Help with animation

Is there a way to calculate how much fps my frames run?
Most of my animations run at different speed each frame and its hard to comunicate this to programmers.
e.g 4th frame of one of my attack animation is 140 miliseconds (in aseprite) and the next frame is 90 (run faster than the previous one). I dont know if there is a equation that help me work around this.
Anyway, thanks in advance

1 second is 1000ms, so you can calculate from there. Divide 1000ms by your desired framerate to get the average frame duration. Divide 1000ms by your average frame duration to get the average frame rate of your animation.

However, if your programmers want a fixed fps, that usually means they want each frame to have the same duration. This can be achieved by

  1. calculating the greatest common factor (GCF) of all the frame durations. This is your new frame duration.
  2. replacing each frame with a number of copies of it so that the total duration matches the old duration of the frame.

For example, if you have an animation consisting of 4 frames that with durations 120, 120, 120, 90 milliseconds, your GCF is 30 milliseconds, and you would need to repeat the first, second, and third frames 4 times each, and the fourth frame 3 times. Your new frame duration would be 30ms, which is about 33fps.

This is something that’s best done via some automated process. For me engine, I wrote a tool that takes the JSON that Aseprite exports alongside spritesheets and adjusts the animations to have a consistent frame duration in this manner, but it can be done by scripting within Aseprite as well, creating linked frames with adjusted durations. It’s probably best done on a copy of your file just prior to export though, to keep the original work file tidy and easy to modify.

1 Like