class Animation: Object

An animation to be played in a display. Yield an AnimationMessage to play one. Animations can be built with a list of frames and durations, or with a custom function.

custom: (fun(time: number, display: Display): boolean)?
frames: Sprite | fun(display: Display, x?: number, y?: number)[]?
durations: (number | table)?
onLoop: (string | fun(self: Animation))?
intervals: number[]?
totalDuration: number?
timer: number

,

position: integer?
status: "paused" | "playing"
staticmethod buildFrames(...: MultiSprite): Sprite[]

Helper function to easily build a list of frames with the same settings over a range of indices.

__new(
    self: Animation,
    frames: Sprite | fun(display: Display, x?: number, y?: number)[] | fun(time: number, display: Display),
    durations: number | table,
    onLoop?: string | fun(animation: Animation)
)
isCustom(self: Animation): boolean
Returns:

_1 (boolean) – Whether this is a custom animation or not.

clone(self: Animation): Animation
update(self: Animation, dt: number)
pause(self: Animation)

Pauses the animation, setting the status to “paused”.

gotoFrame(self: Animation, position: integer)
pauseAtEnd(self: Animation)
pauseAtStart(self: Animation)
resume(self: Animation)
draw(
    self: Animation,
    display: Display,
    x?: number,
    y?: number
)
class MultiSprite: Sprite
range: string

An range string, e.g. “1-5” representing indices 1, 2, 3, 4, 5.

Other members:

Inherited from Sprite: background, color, index, indices, layer, size