API / Animation
Class: Animation
Defined in: animation/Animation.ts:38
The animation player is used to play the animation data and manage the animation states.
Extends
Constructors
Constructor
new Animation(): Animation;
Returns
Animation
Inherited from
Properties
hashCode
readonly hashCode: number;
Defined in: core/BaseObject.ts:156
A unique identification number assigned to the object.
Inherited from
timeScale
timeScale: number;
Defined in: animation/Animation.ts:50
The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast]
Default
1.0
Accessors
animationConfig
Get Signature
get animationConfig(): AnimationConfig;
Defined in: animation/Animation.ts:882
An AnimationConfig instance that can be used quickly.
Returns
animationNames
Get Signature
get animationNames(): readonly string[];
Defined in: animation/Animation.ts:845
The name of all animation data
Returns
readonly string
[]
animations
Get Signature
get animations(): Record<string, AnimationData>;
Defined in: animation/Animation.ts:855
All animation data.
Returns
Record
<string
, AnimationData
>
Set Signature
set animations(value: Record<string, AnimationData>): void;
Defined in: animation/Animation.ts:858
Parameters
Parameter | Type |
---|---|
value | Record <string , AnimationData > |
Returns
void
isCompleted
Get Signature
get isCompleted(): boolean;
Defined in: animation/Animation.ts:818
Check whether all the animation states' playing were finished.
Returns
boolean
isPlaying
Get Signature
get isPlaying(): boolean;
Defined in: animation/Animation.ts:801
Check whether there is an animation state is playing
Returns
boolean
lastAnimationName
Get Signature
get lastAnimationName(): string;
Defined in: animation/Animation.ts:835
The name of the last playing animation state.
Returns
string
lastAnimationState
Get Signature
get lastAnimationState(): AnimationState;
Defined in: animation/Animation.ts:894
The last playing animation state
Returns
Methods
advanceTime()
advanceTime(passedTime: number): void;
Defined in: animation/Animation.ts:168
Internal
Parameters
Parameter | Type |
---|---|
passedTime | number |
Returns
void
fadeIn()
fadeIn(
animationName: string,
fadeInTime: number,
playTimes: number,
layer: number,
group: string,
fadeOutMode: AnimationFadeOutMode): AnimationState;
Defined in: animation/Animation.ts:542
Fade in a specific animation.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
fadeInTime | number | -1.0 | The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) |
playTimes | number | -1 | playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) |
layer | number | 0 | The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) |
group | string | null | The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) |
fadeOutMode | AnimationFadeOutMode | AnimationFadeOutMode.SameLayerAndGroup | The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) |
Returns
The playing animation state.
Example
armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
getBlendState()
getBlendState(
type: string,
name: string,
target: BaseObject): BlendState;
Defined in: animation/Animation.ts:725
Internal
Parameters
Parameter | Type |
---|---|
type | string |
name | string |
target | BaseObject |
Returns
getState()
getState(animationName: string, layer: number): AnimationState;
Defined in: animation/Animation.ts:757
Get a specific animation state.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation state. |
layer | number | -1 | The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) |
Returns
Example
armature.animation.play("walk");
let walkState = armature.animation.getState("walk");
walkState.timeScale = 0.5;
getStates()
getStates(): readonly AnimationState[];
Defined in: animation/Animation.ts:790
Get all the animation states.
Returns
readonly AnimationState
[]
gotoAndPlayByFrame()
gotoAndPlayByFrame(
animationName: string,
frame: number,
playTimes: number): AnimationState;
Defined in: animation/Animation.ts:603
Play a specific animation from the specific frame.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
frame | number | 0 | The start frame of playing. |
playTimes | number | -1 | Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) |
Returns
The played animation state.
gotoAndPlayByProgress()
gotoAndPlayByProgress(
animationName: string,
progress: number,
playTimes: number): AnimationState;
Defined in: animation/Animation.ts:636
Play a specific animation from the specific progress.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
progress | number | 0.0 | The start progress value of playing. |
playTimes | number | -1 | Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) |
Returns
The played animation state.
gotoAndPlayByTime()
gotoAndPlayByTime(
animationName: string,
time: number,
playTimes: number): AnimationState;
Defined in: animation/Animation.ts:574
Play a specific animation from the specific time.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
time | number | 0.0 | The start time point of playing. (In seconds) |
playTimes | number | -1 | Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) |
Returns
The played animation state.
gotoAndStopByFrame()
gotoAndStopByFrame(animationName: string, frame: number): AnimationState;
Defined in: animation/Animation.ts:690
Stop a specific animation at the specific frame.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
frame | number | 0 | The stop frame. |
Returns
The played animation state.
gotoAndStopByProgress()
gotoAndStopByProgress(animationName: string, progress: number): AnimationState;
Defined in: animation/Animation.ts:714
Stop a specific animation at the specific progress.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
progress | number | 0.0 | The stop progress value. |
Returns
The played animation state.
gotoAndStopByTime()
gotoAndStopByTime(animationName: string, time: number): AnimationState;
Defined in: animation/Animation.ts:666
Stop a specific animation at the specific time.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | undefined | The name of animation data. |
time | number | 0.0 | The stop time. (In seconds) |
Returns
The played animation state.
hasAnimation()
hasAnimation(animationName: string): boolean;
Defined in: animation/Animation.ts:780
Check whether a specific animation data is included.
Parameters
Parameter | Type | Description |
---|---|---|
animationName | string | The name of animation data. |
Returns
boolean
init()
init(armature: Armature): void;
Defined in: animation/Animation.ts:157
Internal
Parameters
Parameter | Type |
---|---|
armature | Armature |
Returns
void
play()
play(animationName: string, playTimes: number): AnimationState;
Defined in: animation/Animation.ts:483
Play a specific animation.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | null | The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) |
playTimes | number | -1 | Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) |
Returns
The playing animation state.
Example
armature.animation.play("walk");
playConfig()
playConfig(animationConfig: AnimationConfig): AnimationState;
Defined in: animation/Animation.ts:320
Beta
Play animation with a specific animation config. The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used.
Parameters
Parameter | Type | Description |
---|---|---|
animationConfig | AnimationConfig | The animation config. |
Returns
The playing animation state.
reset()
reset(): void;
Defined in: animation/Animation.ts:272
Clear all animations states.
Returns
void
returnToPool()
returnToPool(): void;
Defined in: core/BaseObject.ts:167
Clear the object and return it back to object pool。
Returns
void
Inherited from
stop()
stop(animationName: string): void;
Defined in: animation/Animation.ts:292
Pause a specific animation state.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
animationName | string | null | The name of animation state. (If not set, it will pause all animations) |
Returns
void
borrowObject()
static borrowObject<T>(objectConstructor: () => T): T;
Defined in: core/BaseObject.ts:136
Get an instance of the specify class from object pool.
Type Parameters
Type Parameter |
---|
T extends BaseObject |
Parameters
Parameter | Type | Description |
---|---|---|
objectConstructor | () => T | The specify class. |
Returns
T
Inherited from
clearPool()
static clearPool(objectConstructor: typeof BaseObject): void;
Defined in: core/BaseObject.ts:111
Clear the cached instances of a specify object pool.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
objectConstructor | typeof BaseObject | null | Specify class. (Clear all cached instances if not set) |
Returns
void
Inherited from
setMaxCount()
static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
Defined in: core/BaseObject.ts:72
Set the maximum cache count of the specify object pool.
Parameters
Parameter | Type | Description |
---|---|---|
objectConstructor | typeof BaseObject | The specify class. (Set all object pools max cache count if not set) |
maxCount | number | Max count. |
Returns
void
Inherited from
toString()
static toString(): string;
Defined in: animation/Animation.ts:39
Returns
string