Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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;
}