Skip to content

AnimationController

Defined in: packages/three-flatland/src/animation/AnimationController.ts:27

Controls animation playback and state.

const controller = new AnimationController();
controller.addAnimation({
name: 'walk',
frames: walkFrames,
fps: 12,
loop: true,
});
controller.play('walk');
// In update loop
controller.update(deltaMs, (frame) => {
sprite.setFrame(frame);
});

new AnimationController(): AnimationController

AnimationController

get currentAnimation(): string | null

Defined in: packages/three-flatland/src/animation/AnimationController.ts:311

Get current animation name.

string | null

addAnimation(animation): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:46

Add an animation definition.

Animation

this


addAnimations(animations): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:54

Add multiple animations.

Animation[]

this


dispose(): void

Defined in: packages/three-flatland/src/animation/AnimationController.ts:352

Dispose of resources.

void


getAnimation(name): Animation | undefined

Defined in: packages/three-flatland/src/animation/AnimationController.ts:75

Get an animation by name.

string

Animation | undefined


getAnimationDuration(name): number

Defined in: packages/three-flatland/src/animation/AnimationController.ts:337

Get animation duration in milliseconds.

string

number


getAnimationNames(): string[]

Defined in: packages/three-flatland/src/animation/AnimationController.ts:82

Get all animation names.

string[]


getCurrentFrame(): SpriteFrame | null

Defined in: packages/three-flatland/src/animation/AnimationController.ts:276

Get current frame.

SpriteFrame | null


getSpeed(): number

Defined in: packages/three-flatland/src/animation/AnimationController.ts:318

Get playback speed.

number


getState(): AnimationState

Defined in: packages/three-flatland/src/animation/AnimationController.ts:286

Get current animation state.

AnimationState


gotoFrame(index): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:158

Go to a specific frame.

number

this


isPlaying(name?): boolean

Defined in: packages/three-flatland/src/animation/AnimationController.ts:301

Check if an animation is playing.

string

boolean


pause(): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:126

Pause the current animation.

this


play(name, options?): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:89

Play an animation.

string

PlayOptions

this


removeAnimation(name): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:64

Remove an animation.

string

this


resume(): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:135

Resume a paused animation.

this


setSpeed(speed): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:325

Set playback speed.

number

this


stop(): this

Defined in: packages/three-flatland/src/animation/AnimationController.ts:144

Stop the current animation.

this


update(deltaMs, onFrame?, onEvent?): void

Defined in: packages/three-flatland/src/animation/AnimationController.ts:173

Update animation state.

number

Time since last update in milliseconds

FrameCallback

Callback when frame changes

EventCallback

Callback when frame event fires

void