AnimationComponent

AnimationComponent

Holds the animation data.

Constructor

new AnimationComponent(pose)

Parameters:
Name Type Description
pose SkeletonPose

pose

Members

layers :Array.<AnimationLayer>

Methods

addLayer(layer, indexopt)

Add a new AnimationLayer to the stack

Parameters:
Name Type Attributes Description
layer AnimationLayer
index number <optional>

if no index is supplied, it's put on top of the stack

attached(entity)

Called when the component was added to an entity. The default implementation
sets the components entity property to the provided value.

Parameters:
Name Type Description
entity Entity

The entity being attached.

detached(entity)

Called when the component was removed from an entity. The default
implementation sets the component's entity property to null.

Parameters:
Name Type Description
entity Entity

The entity being detached.

getCurrentState()

Get current state to which the animationComponent has transitioned.
returns {AbstractState}

getLayerByStateId(stateId) → {AnimationLayer}

Get the layer by id containing a particular state.

Parameters:
Name Type Description
stateId string

getStateById(id) → {AbstractState}

Get the state by id from any layer.

Parameters:
Name Type Description
id string

getStates()

Get available states from all the existing layers.
returns {Array} available state keys

getTransitions()

Get available transitions
returns {Array} available state keys

transitionTo(stateKey, allowDirectSwitch, callback) → {boolean}

Transition to another state. This is shorthand for applying transitions on the state layer provided, if not, transitions will be applied on the base layer , see AnimationLayer.transitionTo for more info

Parameters:
Name Type Description
stateKey string
allowDirectSwitch boolean

Allow the function to directly switch state if transitioning fails (missing or transition already in progress)

callback function

If the target state has a limited number of repeats, this callback is called when the animation finishes.

update()

Update animations