Skip to main content

Playable

Description:

  A base class for an animation model system.

Class Object: Playable Class.

Inherits from: Node.

look

Type: Field.

Description:

  The look of the animation.

Signature:

look: string

speed

Type: Field.

Description:

  The play speed of the animation.

Signature:

speed: number

recovery

Type: Field.

Description:

  The recovery time of the animation, in seconds. Used for doing transitions from one animation to another animation.

Signature:

recovery: number

fliped

Type: Field.

Description:

  Whether the animation is flipped horizontally.

Signature:

fliped: boolean

current

Type: Readonly Field.

Description:

  The current playing animation name.

Signature:

const current: string

lastCompleted

Type: Readonly Field.

Description:

  The last completed animation name.

Signature:

const lastCompleted: string

getKey

Type: Function.

Description:

  Get a key point on the animation model by its name. In the Model animation system, key points are specific points set on the model. In DragonBone, key points are the positions of the armature. In Spine2D, key points are the positions of the point attachments.

Signature:

getKey: function(self: Playable, name: string): Vec2

Parameters:

ParameterTypeDescription
namestringThe name of the key point to get.

Returns:

Return TypeDescription
Vec2The key point value as a Vec2.

play

Type: Function.

Description:

  Plays an animation from the model.

Signature:

play: function(
self: Playable,
name: string,
loop?: boolean --[[false]]
): number

Parameters:

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

Returns:

Return TypeDescription
numberThe duration of the animation in seconds.

stop

Type: Function.

Description:

  Stops the currently playing animation.

Signature:

stop: function(self: Playable)

setSlot

Type: Function.

Description:

  Attaches a child node to a slot on the animation model.

Signature:

setSlot: function(self: Playable, name: string, item: Node)

Parameters:

ParameterTypeDescription
namestringThe name of the slot to set.
itemNodeThe node to set the slot to.

getSlot

Type: Function.

Description:

  Gets the child node attached to the animation model.

Signature:

getSlot: function(self: Playable, name: string): Node | nil

Parameters:

ParameterTypeDescription
namestringThe name of the slot to get.

Returns:

Return TypeDescription
Node|nilThe node in the slot, or nil if there is no node in the slot.

onAnimationEnd

Type: Function.

Description:

  Registers a callback for when an animation has ended.

Signature:

onAnimationEnd: function(self: Playable, callback: function(animationName: string, target: Playable))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function for when the animation has ended.