Skip to content

1681-engine / index / AnimationClip

Interface: AnimationClip ​

Defined in: src/anim/Animator.ts:13

Frame animation of one sprite: which clip plays, which frame it is on. Pure state, advanced by time; a system copies frame onto the sprite (animationSystem).

ts
const clips = { idle: { frames: [0, 1], fps: 2 }, walk: { frames: [2, 3, 4, 5], fps: 10 }, die: { frames: [6, 7, 8], fps: 8, loop: false } };
const a = new Animator(clips, 'idle');
a.play('walk');          // switching to the clip already playing keeps its place
a.update(dt);            // seconds
sprite.setFrame(a.frame);

Properties ​

durations? ​

ts
optional durations?: readonly number[];

Defined in: src/anim/Animator.ts:21

Per-frame lengths in ms, overriding fps (a held key pose, a quick smear).


fps? ​

ts
optional fps?: number;

Defined in: src/anim/Animator.ts:17

Frames per second (default 10). Pixel art usually wants 8–12.


frames ​

ts
frames: readonly (string | number)[];

Defined in: src/anim/Animator.ts:15

Frame names or indices of the sprite sheet, in order.


loop? ​

ts
optional loop?: boolean;

Defined in: src/anim/Animator.ts:19

Start over at the end (default true); otherwise hold the last frame and report it finished.

Released under the MIT License.