Module sprite_animation

Represents a timed sequence of Sprite frames

SpriteAnimation extends BoundObject

Properties

current_index The current frame index of the animation.
fps The rate the animation advances in frames per second.
repeats (bool) Whether the animation should repeat.

Class Methods

SpriteAnimation:new (...) Create a new SpriteAnimation from a sequence of frames.

Hooks

complete (self) Called when SpriteAnimation reaches the end.


Properties

Properties. Significant fields on an instance.
current_index
The current frame index of the animation. This is relative to the animation, not the sprite.

Index 0 is the first frame in the animation.

fps
The rate the animation advances in frames per second.
repeats
(bool) Whether the animation should repeat.

Default true

Class Methods

Class Methods. Must be called on Class, with a capital leading character. e.g. Class:method("foo")
SpriteAnimation:new (...)
Create a new SpriteAnimation from a sequence of frames.

Parameters:

  • ... number A variable list of Sprite frames to compose the animation with.

Returns:

    SpriteAnimation

Usage:

    local anim = SpriteAnimation:new(1, 2, 3, 2) -- Walking

Hooks

Hooks. Callbacks implemented in subclasses to customize behavior. Hooks are called on individual instances.
complete (self)
Called when SpriteAnimation reaches the end.

This is not called if repeats is true

Parameters:

  • self SpriteAnimation The SpriteAnimation instance
generated by LDoc 1.3.12