pixi-dragonbones-runtime
Version:
DragonBones Runtime for Pixi.js
418 lines (417 loc) • 12.2 kB
TypeScript
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { Armature } from "../armature/index.js";
import { BaseObject, AnimationBlendType } from "../core/index.js";
import { AnimationData, AnimationConfig, TimelineData } from "../model/index.js";
import { ActionTimelineState } from "./TimelineState.js";
/**
* [en] The animation state is generated when the animation data is played.
*
* [zh] 动画状态由播放动画数据时产生。
*
* @see Animation
* @see AnimationData
* @version DragonBones 3.0
*/
export declare class AnimationState extends BaseObject {
static toString(): string;
/**
* @private
*/
actionEnabled: boolean;
/**
* @private
*/
additive: boolean;
/**
* [en] Whether the animation state has control over the display object properties of the slots.
* Sometimes blend a animation state does not want it to control the display object properties of the slots,
* especially if other animation state are controlling the display object properties of the slots.
*
* [zh] 动画状态是否对插槽的显示对象属性有控制权。
* 有时混合一个动画状态并不希望其控制插槽的显示对象属性,
* 尤其是其他动画状态正在控制这些插槽的显示对象属性时。
*
* @default true
* @version DragonBones 5.0
*/
displayControl: boolean;
/**
* [en] Whether to reset the objects without animation to the armature pose when the animation state is start to play.
* This property should usually be set to false when blend multiple animation states.
*
* [zh] 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。
* 通常在混合多个动画状态时应该将该属性设置为 false。
*
* @default true
* @version DragonBones 5.1
*/
resetToPose: boolean;
/**
* @private
*/
blendType: AnimationBlendType;
/**
* [en] The play times. [0: Loop play, [1~N]: Play N times]
*
* [zh] 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次]
*
* @version DragonBones 3.0
*/
playTimes: number;
/**
* [en] The blend layer.
* High layer animation state will get the blend weight first.
* When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned.
*
* [zh] 混合图层。
* 图层高的动画状态会优先获取混合权重。
* 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。
*
* @readonly
* @version DragonBones 5.0
*/
layer: number;
/**
* [en] The play speed.
* The value is an overlay relationship with {@link Animation#timeScale}.
* [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
*
* [zh] 播放速度。
* 该值与 {@link Animation#timeScale} 是叠加关系。
* [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放]
*
* @default 1.0
* @version DragonBones 3.0
*/
timeScale: number;
/**
* @private
*/
parameterX: number;
/**
* @private
*/
parameterY: number;
/**
* @private
*/
positionX: number;
/**
* @private
*/
positionY: number;
/**
* [en] The auto fade out time when the animation state play completed.
* [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds)
*
* [zh] 动画状态播放完成后的自动淡出时间。
* [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位)
*
* @default -1.0
* @version DragonBones 5.0
*/
autoFadeOutTime: number;
/**
* @private
*/
fadeTotalTime: number;
/**
* [en] The name of the animation state. (Can be different from the name of the animation data)
*
* [zh] 动画状态名称。 (可以不同于动画数据)
*
* @readonly
* @version DragonBones 5.0
*/
name: string;
/**
* [en] The blend group name of the animation state.
* This property is typically used to specify the substitution of multiple animation states blend.
*
* [zh] 混合组名称。
* 该属性通常用来指定多个动画状态混合时的相互替换关系。
*
* @readonly
* @version DragonBones 5.0
*/
group: string;
private _timelineDirty;
/**
* - xx: Play Enabled, Fade Play Enabled
* @internal
*/
_playheadState: number;
/**
* -1: Fade in, 0: Fade complete, 1: Fade out;
* @internal
*/
_fadeState: number;
/**
* -1: Fade start, 0: Fading, 1: Fade complete;
* @internal
*/
_subFadeState: number;
/**
* @internal
*/
_position: number;
/**
* @internal
*/
_duration: number;
private _weight;
private _fadeTime;
private _time;
/**
* @internal
*/
_fadeProgress: number;
/**
* @internal
*/
_weightResult: number;
private readonly _boneMask;
private readonly _boneTimelines;
private readonly _boneBlendTimelines;
private readonly _slotTimelines;
private readonly _slotBlendTimelines;
private readonly _constraintTimelines;
private readonly _animationTimelines;
private readonly _poseTimelines;
private _animationData;
private _armature;
/**
* @internal
*/
_actionTimeline: ActionTimelineState;
private _zOrderTimeline;
private _activeChildA;
private _activeChildB;
/**
* @internal
*/
_parent: AnimationState | null;
protected _onClear(): void;
private _updateTimelines;
private _updateBoneAndSlotTimelines;
private _advanceFadeTime;
/**
* @internal
*/
init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void;
/**
* @internal
*/
advanceTime(passedTime: number, cacheFrameRate: number): void;
/**
* [en] Continue play.
*
* [zh] 继续播放。
*
* @version DragonBones 3.0
*/
play(): void;
/**
* [en] Stop play.
*
* [zh] 暂停播放。
*
* @version DragonBones 3.0
*/
stop(): void;
/**
* [en] Fade out the animation state.
*
* [zh] 淡出动画状态。
*
* @param fadeOutTime - [en] The fade out time. (In seconds)
* @param fadeOutTime - [zh] 淡出时间。 (以秒为单位)
*
* @param pausePlayhead - [en] Whether to pause the animation playing when fade out.
* @param pausePlayhead - [zh] 淡出时是否暂停播放。
*
* @version DragonBones 3.0
*/
fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void;
/**
* [en] Check if a specific bone mask is included.
*
* [zh] 检查是否包含特定骨骼遮罩。
*
* @param boneName - [en] The bone name.
* @param boneName - [zh] 骨骼名称。
*
* @version DragonBones 3.0
*/
containsBoneMask(boneName: string): boolean;
/**
* [en] Add a specific bone mask.
*
* [zh] 添加特定的骨骼遮罩。
*
* @param boneName - [en] The bone name.
* @param boneName - [zh] 骨骼名称。
*
* @param recursive - [en] Whether or not to add a mask to the bone's sub-bone.
* @param recursive - [zh] 是否为该骨骼的子骨骼添加遮罩。
*
* @version DragonBones 3.0
*/
addBoneMask(boneName: string, recursive?: boolean): void;
/**
* [en] Remove the mask of a specific bone.
*
* [zh] 删除特定骨骼的遮罩。
*
* @param boneName - [en] The bone name.
* @param boneName - [zh] 骨骼名称。
*
* @param recursive - [en] Whether to remove the bone's sub-bone mask.
* @param recursive - [zh] 是否删除该骨骼的子骨骼遮罩。
*
* @version DragonBones 3.0
*/
removeBoneMask(boneName: string, recursive?: boolean): void;
/**
* [en] Remove all bone masks.
*
* [zh] 删除所有骨骼遮罩。
*
* @version DragonBones 3.0
*/
removeAllBoneMask(): void;
/**
* @private
*/
addState(animationState: AnimationState, timelineDatas?: TimelineData[] | null): void;
/**
* @internal
*/
activeTimeline(): void;
/**
* [en] Whether the animation state is fading in.
*
* [zh] 是否正在淡入。
*
* @version DragonBones 5.1
*/
get isFadeIn(): boolean;
/**
* [en] Whether the animation state is fading out.
*
* [zh] 是否正在淡出。
*
* @version DragonBones 5.1
*/
get isFadeOut(): boolean;
/**
* [en] Whether the animation state is fade completed.
*
* [zh] 是否淡入或淡出完毕。
*
* @version DragonBones 5.1
*/
get isFadeComplete(): boolean;
/**
* [en] Whether the animation state is playing.
*
* [zh] 是否正在播放。
*
* @version DragonBones 3.0
*/
get isPlaying(): boolean;
/**
* [en] Whether the animation state is play completed.
*
* [zh] 是否播放完毕。
*
* @version DragonBones 3.0
*/
get isCompleted(): boolean;
/**
* [en] The times has been played.
*
* [zh] 已经循环播放的次数。
*
* @version DragonBones 3.0
*/
get currentPlayTimes(): number;
/**
* [en] The total time. (In seconds)
*
* [zh] 总播放时间。 (以秒为单位)
*
* @version DragonBones 3.0
*/
get totalTime(): number;
/**
* [en] The time is currently playing. (In seconds)
*
* [zh] 当前播放的时间。 (以秒为单位)
*
* @version DragonBones 3.0
*/
get currentTime(): number;
set currentTime(value: number);
/**
* [en] The blend weight.
*
* [zh] 混合权重。
*
* @default 1.0
* @version DragonBones 5.0
*/
get weight(): number;
set weight(value: number);
/**
* [en] The animation data.
*
* [zh] 动画数据。
*
* @see AnimationData
* @version DragonBones 3.0
*/
get animationData(): AnimationData;
}
/**
* @internal
*/
export declare class BlendState extends BaseObject {
static readonly BONE_TRANSFORM: string;
static readonly BONE_ALPHA: string;
static readonly SURFACE: string;
static readonly SLOT_DEFORM: string;
static readonly SLOT_ALPHA: string;
static readonly SLOT_Z_INDEX: string;
static toString(): string;
dirty: number;
layer: number;
leftWeight: number;
layerWeight: number;
blendWeight: number;
target: BaseObject;
protected _onClear(): void;
update(animationState: AnimationState): boolean;
reset(): void;
}