FormatFrame()
Provides the appropriate frame based on the animation, along with looping and reverse options.
function FormatFrame(
frame: Int,
animation: Animation,
reverse: Bool,
isLoop: Bool,
): Int {
const lastFrame: Int = animation.keyframes[-1].frame;
if (isLoop) {
frame %= lastFrame + 1;
}
if (reverse) {
frame = lastFrame - frame;
}
return frame;
}