Skip to main content

AnimationsController

Manages animation playback, state/event grouping, track allocation, and Spine event listeners. Accessed via layout.animations.

Methods

registerSpine

registerSpine(spineID: string, spine: Spine): void

Registers a spine instance, wiring up its animation metadata and event listeners. Called internally during spine creation.


getAall

getAall(): string[]

Returns all registered animation names (without modifiers).


getStates

getStates(): string[]

Returns all registered state names (from state_<name>/ folders).


getEvents

getEvents(): string[]

Returns all registered event names (from event_<name>/ folders).


getActive

getActive(): string[]

Returns the names of all currently playing (non-looping) animations.


getLooping

getLooping(): string[]

Returns the names of all currently looping animations.


addEventListener

addEventListener(event: string, fn: (event: unknown) => void): void

Subscribes a callback to a named Spine skeleton event. Multiple listeners per event are supported.


playState

playState(stateName: string): Promise<void>

Plays all animations grouped under the given state name (e.g. "idle" triggers every animation in state_idle/).


playEvent

playEvent(eventName: string, spineID: string): Promise<void>

Plays all animations grouped under the given event name and notifies registered listeners.


playAnimationByName

playAnimationByName(animationName: string, playSolo?: boolean, trackID?: number): Promise<void>

Plays the named animation on every spine that has it. Pass playSolo=true to stop all other animations first.


playSolo

playSolo(animationName: string): Promise<void>

Stops all running animations, then plays the named animation on all spines that have it.


playInstanceAnimation

playInstanceAnimation(spineID: string, animation: string, playSolo?: boolean, trackID?: number): Promise<void>

Plays a specific animation on a single spine by ID. Resolves when the animation completes (looping animations resolve immediately).


playInstanceAnimationLastFrame

playInstanceAnimationLastFrame(spineID: string, animation: string, playSolo?: boolean): Promise<void>

Plays an animation then immediately seeks to its last frame, effectively showing the end pose.


stopAll

stopAll(): void

Stops all animations on all spines and resets them to their setup pose.


stopAllBySpineID

stopAllBySpineID(spineID: string): void

Stops all animations on a specific spine and resets it to the setup pose.


stopAnimation

stopAnimation(spineID: string, animation: string): void

Stops a specific animation on a specific spine, clearing its track.


pauseState

pauseState(stateName: string): void

Pauses all spines involved in the given state by setting their timeScale to 0.


pauseSpineByID

pauseSpineByID(spineID: string): void

Pauses a specific spine by setting its timeScale to 0.


speed (setter)

set speed(value: number)

Sets the global playback speed for all spines (timeScale).