API Docs for:
Show:

Animation Class

A component class which holds animations and logic recquired to play them.

Constructor

Animation

()

Item Index

Methods

Methods

add

(
  • handle
  • name
)

Registers a new animation. Overwrites previously registered animations with the same name.

Parameters:

  • handle AssetHandle

    The animation asset handle.

  • name String

    Name of the animation. From now on, the animation will be referenced by this name within this component.

get

(
  • name
)
AssetHandle | Null | Undefined

Retrieves a registered animation.

Parameters:

  • name String

    Name of the animation.

Returns:

AssetHandle | Null | Undefined: Handle to the animation asset that was registered with the given name. If the animation wasn't registered, the function will return null or undefined.

has

(
  • name
)
Boolean

Checks whether an animation with the given name was registered.

Parameters:

  • name String

    Name of the animation.

Returns:

Boolean:

play

(
  • name
  • [priority]
  • [rate]
  • [finishedCallback]
  • [callbackData]
)

Schedules playing of an animation. The new animation will be played if there's no animation currently playing or if the priority of the new animation is at least as high as the one currently playing. If the animation being played is the same as the currently playing animation, then only the rate, priority and callbacks will be set.

Parameters:

  • name String

    Name of the animation.

  • [priority] Number optional

    The animation's priority. A greater number signifies greater priority. If the priority is smaller than the priority of the currently playing animation, the new animation will not be played. If not provided, defaults to Number.NEGATIVE_INFINITY.

  • [rate] Number optional

    Rate at which the new animation should be played. A rate of 0.5 means that the animation will play twice as fast as specified in the asset file, while a rate of 2 means that it'll play two times slower. If this value is not provided or is less than or equal to 0, then the rate will default to 1.

  • [finishedCallback] Function optional

    A function to be called when the animation finishes playing. The callback will not be called for looping animations (obviously) and animations that get overwritten by playing other animations before they can finish.

  • [callbackData] Object optional

    User specified data for the callback.

remove

(
  • name
)

Removes a registered animation.

Parameters:

  • name String

    Name of the animation.