AnimationController
Defined in: packages/three-flatland/src/animation/AnimationController.ts:27
Controls animation playback and state.
Example
Section titled “Example”const controller = new AnimationController();controller.addAnimation({ name: 'walk', frames: walkFrames, fps: 12, loop: true,});controller.play('walk');
// In update loopcontroller.update(deltaMs, (frame) => { sprite.setFrame(frame);});Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AnimationController():
AnimationController
Returns
Section titled “Returns”AnimationController
Accessors
Section titled “Accessors”currentAnimation
Section titled “currentAnimation”Get Signature
Section titled “Get Signature”get currentAnimation():
string|null
Defined in: packages/three-flatland/src/animation/AnimationController.ts:311
Get current animation name.
Returns
Section titled “Returns”string | null
Methods
Section titled “Methods”addAnimation()
Section titled “addAnimation()”addAnimation(
animation):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:46
Add an animation definition.
Parameters
Section titled “Parameters”animation
Section titled “animation”Returns
Section titled “Returns”this
addAnimations()
Section titled “addAnimations()”addAnimations(
animations):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:54
Add multiple animations.
Parameters
Section titled “Parameters”animations
Section titled “animations”Returns
Section titled “Returns”this
dispose()
Section titled “dispose()”dispose():
void
Defined in: packages/three-flatland/src/animation/AnimationController.ts:352
Dispose of resources.
Returns
Section titled “Returns”void
getAnimation()
Section titled “getAnimation()”getAnimation(
name):Animation|undefined
Defined in: packages/three-flatland/src/animation/AnimationController.ts:75
Get an animation by name.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Animation | undefined
getAnimationDuration()
Section titled “getAnimationDuration()”getAnimationDuration(
name):number
Defined in: packages/three-flatland/src/animation/AnimationController.ts:337
Get animation duration in milliseconds.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”number
getAnimationNames()
Section titled “getAnimationNames()”getAnimationNames():
string[]
Defined in: packages/three-flatland/src/animation/AnimationController.ts:82
Get all animation names.
Returns
Section titled “Returns”string[]
getCurrentFrame()
Section titled “getCurrentFrame()”getCurrentFrame():
SpriteFrame|null
Defined in: packages/three-flatland/src/animation/AnimationController.ts:276
Get current frame.
Returns
Section titled “Returns”SpriteFrame | null
getSpeed()
Section titled “getSpeed()”getSpeed():
number
Defined in: packages/three-flatland/src/animation/AnimationController.ts:318
Get playback speed.
Returns
Section titled “Returns”number
getState()
Section titled “getState()”getState():
AnimationState
Defined in: packages/three-flatland/src/animation/AnimationController.ts:286
Get current animation state.
Returns
Section titled “Returns”gotoFrame()
Section titled “gotoFrame()”gotoFrame(
index):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:158
Go to a specific frame.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
isPlaying()
Section titled “isPlaying()”isPlaying(
name?):boolean
Defined in: packages/three-flatland/src/animation/AnimationController.ts:301
Check if an animation is playing.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”boolean
pause()
Section titled “pause()”pause():
this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:126
Pause the current animation.
Returns
Section titled “Returns”this
play()
Section titled “play()”play(
name,options?):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:89
Play an animation.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”this
removeAnimation()
Section titled “removeAnimation()”removeAnimation(
name):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:64
Remove an animation.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
resume()
Section titled “resume()”resume():
this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:135
Resume a paused animation.
Returns
Section titled “Returns”this
setSpeed()
Section titled “setSpeed()”setSpeed(
speed):this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:325
Set playback speed.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”this
stop()
Section titled “stop()”stop():
this
Defined in: packages/three-flatland/src/animation/AnimationController.ts:144
Stop the current animation.
Returns
Section titled “Returns”this
update()
Section titled “update()”update(
deltaMs,onFrame?,onEvent?):void
Defined in: packages/three-flatland/src/animation/AnimationController.ts:173
Update animation state.
Parameters
Section titled “Parameters”deltaMs
Section titled “deltaMs”number
Time since last update in milliseconds
onFrame?
Section titled “onFrame?”FrameCallback
Callback when frame changes
onEvent?
Section titled “onEvent?”EventCallback
Callback when frame event fires
Returns
Section titled “Returns”void