Class: core/SingleState

core/SingleState(optionsopt)

Class for playing a single animation clip.

Constructor

new core/SingleState(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

Options for the animation state.

Properties
Name Type Attributes Default Description
name string <optional>

Name for the animation state. Names must be
unique for the layer the state is applied to.

weight weight <optional>
0

The 0-1 amount of influence the state will have.

timeScale timeScale <optional>
1

Factor to scale the playback speed of the
animation.

loopCount number <optional>
Infinity

Number of times the animation should
repeat before finishing.

blendMode string <optional>
DefaultLayerBlendMode

Type of
blending the animation should use.

Extends

Members

(readonly) blendMode :string

Gets the type of blending used for the animation.

Type:
  • string

(readonly) internalWeight :number

Gets the internal weight.

Type:
  • number
Overrides:

loopCount :number

Gets and sets the number of times the animation will repeat before finishing.

Type:
  • number

normalizedTime :number

Gets and sets the normalized playing time of the current animation

Type:
  • number

paused :number

Gets whether or not the state is currently paused.

Type:
  • number
Overrides:

timeScale :number

Gets and sets the a factor to scale animation playback speed with.

Type:
  • number

(readonly) timeScalePending :boolean

Gets whether or not the timeScale is currently being animated.

Type:
  • boolean

weight :number

Gets and sets the user defined weight.

Type:
  • number
Overrides:

(readonly) weightPending :boolean

Gets whether or not the weight is currently being animated.

Type:
  • boolean
Overrides:

Methods

cancel() → {boolean}

Cancel playback of the state and cancel any pending promises.

Overrides:
Returns:
Type
boolean

deactivate()

Force the internal weight to 0. Should be called before switching or transitioning
to a new state.

Overrides:

discard()

Cancel any pending promises and remove reference to them.

Overrides:

pause() → {boolean}

Pause playback of the state. This prevents pending promises from being executed.

Overrides:
Returns:
Type
boolean

play(onFinishopt, onErroropt, onCancelopt) → {Deferred}

Start playback of the state from the beginning.

Parameters:
Name Type Attributes Description
onFinish function <optional>

Function to execute when the state finishes.

onError function <optional>

Function to execute if the state encounters
an error during playback.

onCancel function <optional>

Function to execute if playback is canceled.

Overrides:
Returns:
Type
Deferred

resume(onFinishopt, onErroropt, onCancelopt) → {Deferred}

Resume playback of the state.

Parameters:
Name Type Attributes Description
onFinish function <optional>

Function to execute when the state finishes.

onError function <optional>

Function to execute if the state encounters
an error during playback.

onCancel function <optional>

Function to execute if playback is canceled.

Overrides:
Returns:
Type
Deferred

setTimeScale(weight, secondsopt, easingFnopt) → {Deferred}

Updates the timeScale value over time.

Parameters:
Name Type Attributes Default Description
weight number

The target timeScale value.

seconds number <optional>
0

The amount of time it will take to reach the
target timeScale.

easingFn function <optional>

The easing function to use for interpolation.

Returns:
Type
Deferred

setWeight(weight, secondsopt, easingFnopt) → {Deferred}

Updates the user defined weight over time.

Parameters:
Name Type Attributes Default Description
weight number

The target weight value.

seconds number <optional>
0

The amount of time it will take to reach the
target weight.

easingFn function <optional>

The easing function to use for interpolation.

Overrides:
Returns:
Type
Deferred

stop() → {boolean}

Stop playback of the state and resolve any pending promises.

Overrides:
Returns:
Type
boolean

update(deltaTime)

Update any values that need to be evaluated every frame.

Parameters:
Name Type Description
deltaTime number

Time in milliseconds since the last update.

Overrides:

updateInternalWeight(factor)

Multiplies the user weight by a factor to determine the internal weight.

Parameters:
Name Type Description
factor number

0-1 multiplier to apply to the user weight.

Overrides: