Skip to main content

Model

Description:

  Another implementation of the 'Playable' record.

Class Object: Model Class.

Inherits from: Playable.

reversed

Type: Field.

Description:

  Whether the animation model will be played in reverse.

Signature:

reversed: boolean

duration

Type: Readonly Field.

Description:

  The duration of the current animation.

Signature:

const duration: number

playing

Type: Readonly Field.

Description:

  Whether the animation model is currently playing.

Signature:

const playing: boolean

paused

Type: Readonly Field.

Description:

  Whether the animation model is currently paused.

Signature:

const paused: boolean

hasAnimation

Type: Function.

Description:

  Check if an animation exists in the model.

Signature:

hasAnimation: function(self: Model, name: string): boolean

Parameters:

ParameterTypeDescription
namestringThe name of the animation to check.

Returns:

Return TypeDescription
booleanWhether the animation exists in the model or not.

pause

Type: Function.

Description:

  Pauses the currently playing animation.

Signature:

pause: function(self: Model)

resume

Type: Function.

Description:

  Resumes the currently paused animation, or plays a new animation if specified.

Signature:

resume: function(
self: Model,
name?: string,
loop?: boolean --[[false]]
)

Parameters:

ParameterTypeDescription
namestring[optional] The name of the animation to play.
loopboolean[optional] Whether to loop the animation or not (default is false).

reset

Type: Function.

Description:

  Resets the current animation to its initial state.

Signature:

reset: function(self: Model)

updateTo

Type: Function.

Description:

  Updates the animation to the specified time, and optionally in reverse.

Signature:

updateTo: function(
self: Model,
elapsed: number,
reversed?: boolean --[[false]]
)

Parameters:

ParameterTypeDescription
elapsednumberThe time to update to.
reversedboolean[optional] Whether to play the animation in reverse (default is false).

getNodeByName

Type: Function.

Description:

  Gets the node with the specified name.

Signature:

getNodeByName: function(self: Model, name: string): Node

Parameters:

ParameterTypeDescription
namestringThe name of the node to get.

Returns:

Return TypeDescription
NodeThe node with the specified name.

eachNode

Type: Function.

Description:

  Calls the specified function for each node in the model, and stops if the function returns false.

Signature:

eachNode: function(self: Model, func: function(Node): boolean): boolean

Parameters:

ParameterTypeDescription
funcfunctionThe function to call for each node.

Returns:

Return TypeDescription
booleanWhether the function was called for all nodes or not.