Skip to content

API / Armature

类: Armature ​

定义于: armature/Armature.ts:44

骨架是骨骼动画系统的核心。

继承 ​

实现 ​

构造函数 ​

构造函数 ​

ts
new Armature(): Armature;

返回 ​

Armature

继承自 ​

BaseObject.constructor

属性 ​

_alphaDirty ​

ts
_alphaDirty: boolean;

定义于: armature/Armature.ts:80

Internal


_armatureData ​

ts
_armatureData: ArmatureData;

定义于: armature/Armature.ts:102

Internal


_cacheFrameIndex ​

ts
_cacheFrameIndex: number;

定义于: armature/Armature.ts:86

Internal


_constraints ​

ts
readonly _constraints: Constraint[] = [];

定义于: armature/Armature.ts:97

Internal


_dragonBones ​

ts
_dragonBones: DragonBones;

定义于: armature/Armature.ts:114

Internal


_globalAlpha ​

ts
_globalAlpha: number;

定义于: armature/Armature.ts:91

Internal


_lockUpdate ​

ts
_lockUpdate: boolean;

定义于: armature/Armature.ts:70

Internal


_parent ​

ts
_parent: Slot;

定义于: armature/Armature.ts:119

Internal


_replaceTextureAtlasData ​

ts
_replaceTextureAtlasData: TextureAtlasData = null;

定义于: armature/Armature.ts:109

Internal


_zIndexDirty ​

ts
_zIndexDirty: boolean;

定义于: armature/Armature.ts:76

Internal


hashCode ​

ts
readonly hashCode: number;

定义于: core/BaseObject.ts:156

分配给此实例的唯一标识号。

继承自 ​

BaseObject.hashCode


inheritAnimation ​

ts
inheritAnimation: boolean;

定义于: armature/Armature.ts:62


stopped ​

ts
stopped: boolean = false;

定义于: armature/Armature.ts:61

是否继承父骨架的动画控制。 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。

默认值 ​

ts
true

实现了 ​

IAnimatable.stopped

访问器 ​

animation ​

Getter 签名 ​

ts
get animation(): Animation;

定义于: armature/Armature.ts:777

动画播放器。

返回 ​

Animation


armatureData ​

Getter 签名 ​

ts
get armatureData(): ArmatureData;

定义于: armature/Armature.ts:766

骨架数据。

返回 ​

ArmatureData


cacheFrameRate ​

Getter 签名 ​

ts
get cacheFrameRate(): number;

定义于: armature/Armature.ts:732

动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。

示例 ​
ts
    armature.cacheFrameRate = 24;
返回 ​

number

Setter 签名 ​

ts
set cacheFrameRate(value: number): void;

定义于: armature/Armature.ts:735

参数 ​
参数类型
valuenumber
返回 ​

void


clock ​

Getter 签名 ​

ts
get clock(): WorldClock;

定义于: armature/Armature.ts:836

当前所属的 WordClock 实例。

示例 ​
ts
    armature.clock = factory.clock; // 将骨架添加到时钟。
    armature.clock = null; // 将骨架从时钟移除。
返回 ​

WorldClock

Setter 签名 ​

ts
set clock(value: WorldClock): void;

定义于: armature/Armature.ts:839

当前所属的 WordClock 实例。

Examples ​
ts
    armature.clock = factory.clock; // Add armature to clock.
    armature.clock = null; // Remove armature from clock.
ts
    armature.clock = factory.clock; // 将骨架添加到时钟。
    armature.clock = null; // 将骨架从时钟移除。
参数 ​
参数类型
valueWorldClock
返回 ​

void

当前所属的 WordClock 实例。

示例 ​

ts
    armature.clock = factory.clock; // 将骨架添加到时钟。
    armature.clock = null; // 将骨架从时钟移除。

实现了 ​

IAnimatable.clock


display ​

Getter 签名 ​

ts
get display(): any;

定义于: armature/Armature.ts:807

显示容器实例。 插槽的显示对象都会以此显示容器为父级。 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。

返回 ​

any


eventDispatcher ​

Getter 签名 ​

ts
get eventDispatcher(): IEventDispatcher;

定义于: armature/Armature.ts:793

该骨架的 EventDispatcher 实例。

返回 ​

IEventDispatcher


flipX ​

Getter 签名 ​

ts
get flipX(): boolean;

定义于: armature/Armature.ts:684

是否将骨架水平翻转。

返回 ​

boolean

Setter 签名 ​

ts
set flipX(value: boolean): void;

定义于: armature/Armature.ts:687

参数 ​
参数类型
valueboolean
返回 ​

void


flipY ​

Getter 签名 ​

ts
get flipY(): boolean;

定义于: armature/Armature.ts:702

是否将骨架垂直翻转。

返回 ​

boolean

Setter 签名 ​

ts
set flipY(value: boolean): void;

定义于: armature/Armature.ts:705

参数 ​
参数类型
valueboolean
返回 ​

void


name ​

Getter 签名 ​

ts
get name(): string;

定义于: armature/Armature.ts:755

骨架名称。

返回 ​

string


parent ​

Getter 签名 ​

ts
get parent(): Slot;

定义于: armature/Armature.ts:870

该骨架所属的父插槽。

返回 ​

Slot


proxy ​

Getter 签名 ​

ts
get proxy(): IArmatureProxy;

定义于: armature/Armature.ts:783

Pivate ​
返回 ​

IArmatureProxy


replacedTexture ​

Setter 签名 ​

ts
set replacedTexture(value: any): void;

定义于: armature/Armature.ts:816

参数 ​
参数类型
valueany
返回 ​

void

方法 ​

_addBone() ​

ts
_addBone(value: Bone): void;

定义于: armature/Armature.ts:210

Internal

参数 ​

参数类型
valueBone

返回 ​

void


_addConstraint() ​

ts
_addConstraint(value: Constraint): void;

定义于: armature/Armature.ts:226

Internal

参数 ​

参数类型
valueConstraint

返回 ​

void


_addSlot() ​

ts
_addSlot(value: Slot): void;

定义于: armature/Armature.ts:218

Internal

参数 ​

参数类型
valueSlot

返回 ​

void


_bufferAction() ​

ts
_bufferAction(action: EventObject, append: boolean): void;

定义于: armature/Armature.ts:234

Internal

参数 ​

参数类型
actionEventObject
appendboolean

返回 ​

void


_sortZOrder() ​

ts
_sortZOrder(slotIndices: number[] | Int16Array<ArrayBuffer>, offset: number): void;

定义于: armature/Armature.ts:184

Internal

参数 ​

参数类型
slotIndicesnumber[] | Int16Array<ArrayBuffer>
offsetnumber

返回 ​

void


advanceTime() ​

ts
advanceTime(passedTime: number): void;

定义于: armature/Armature.ts:286

更新时间。

参数 ​

参数类型描述
passedTimenumber前进的时间。 (以秒为单位)

返回 ​

void

实现了 ​

IAnimatable.advanceTime


containsPoint() ​

ts
containsPoint(x: number, y: number): Slot;

定义于: armature/Armature.ts:448

检查特定点是否在某个插槽的自定义边界框内。 点的坐标系为骨架内坐标系。 自定义边界框需要在 DragonBones Pro 中自定义。

参数 ​

参数类型描述
xnumber点的水平坐标。
ynumber点的垂直坐标。

返回 ​

Slot


dispose() ​

ts
dispose(): void;

定义于: armature/Armature.ts:256

释放骨架。 (回收到对象池)

返回 ​

void

示例 ​

ts
    removeChild(armature.display);
    armature.dispose();

getBone() ​

ts
getBone(name: string): Bone;

定义于: armature/Armature.ts:588

获取特定的骨骼。

参数 ​

参数类型描述
namestring骨骼名称。

返回 ​

Bone


getBoneByDisplay() ​

ts
getBoneByDisplay(display: any): Bone;

定义于: armature/Armature.ts:608

通过显示对象获取特定的骨骼。

参数 ​

参数类型描述
displayany显示对象。

返回 ​

Bone


getBones() ​

ts
getBones(): Bone[];

定义于: armature/Armature.ts:663

获取所有的骨骼。

返回 ​

Bone[]


getDisplay() ​

ts
getDisplay(): any;

定义于: armature/Armature.ts:880

已废弃,请参考 #display。

返回 ​

any

已被弃用 ​


getSlot() ​

ts
getSlot(name: string): Slot;

定义于: armature/Armature.ts:624

获取特定的插槽。

参数 ​

参数类型描述
namestring插槽名称。

返回 ​

Slot


getSlotByDisplay() ​

ts
getSlotByDisplay(display: any): Slot;

定义于: armature/Armature.ts:644

通过显示对象获取特定的插槽。

参数 ​

参数类型描述
displayany显示对象。

返回 ​

Slot


getSlots() ​

ts
getSlots(): Slot[];

定义于: armature/Armature.ts:674

获取所有的插槽。

返回 ​

Slot[]


init() ​

ts
init(
   armatureData: ArmatureData, 
   proxy: IArmatureProxy, 
   display: any, 
   dragonBones: DragonBones): void;

定义于: armature/Armature.ts:265

Internal

参数 ​

参数类型
armatureDataArmatureData
proxyIArmatureProxy
displayany
dragonBonesDragonBones

返回 ​

void


intersectsSegment() ​

ts
intersectsSegment(
   xA: number, 
   yA: number, 
   xB: number, 
   yB: number, 
   intersectionPointA: object, 
   intersectionPointB: object, 
   normalRadians: object): Slot;

定义于: armature/Armature.ts:492

检查特定线段是否与骨架的某个插槽的自定义边界框相交。 线段和交点的坐标系均为骨架内坐标系。 自定义边界框需要在 DragonBones Pro 中自定义。

参数 ​

参数类型默认值描述
xAnumberundefined线段起点的水平坐标。
yAnumberundefined线段起点的垂直坐标。
xBnumberundefined线段终点的水平坐标。
yBnumberundefined线段终点的垂直坐标。
intersectionPointA{ x: number; y: number; }null线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
intersectionPointA.xnumberundefined-
intersectionPointA.ynumberundefined-
intersectionPointB{ x: number; y: number; }null线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点)
intersectionPointB.xnumberundefined-
intersectionPointB.ynumberundefined-
normalRadians{ x: number; y: number; }null交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线)
normalRadians.xnumberundefined-
normalRadians.ynumberundefined-

返回 ​

Slot

线段从起点到终点相交的第一个自定义边界框的插槽。


invalidUpdate() ​

ts
invalidUpdate(boneName: string, updateSlot: boolean): void;

定义于: armature/Armature.ts:404

强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。

参数 ​

参数类型默认值描述
boneNamestringnull骨骼名称。 (如果未设置,将更新所有骨骼)
updateSlotbooleanfalse是否更新骨骼的插槽。 (默认: false)

返回 ​

void


returnToPool() ​

ts
returnToPool(): void;

定义于: core/BaseObject.ts:167

清除该实例的所有数据并将其返还对象池。

返回 ​

void

继承自 ​

BaseObject.returnToPool


borrowObject() ​

ts
static borrowObject<T>(objectConstructor: () => T): T;

定义于: core/BaseObject.ts:136

从对象池中获取特定类的实例。

类型参数 ​

类型参数
T extends BaseObject

参数 ​

参数类型描述
objectConstructor() => T特定的类。

返回 ​

T

继承自 ​

BaseObject.borrowObject


clearPool() ​

ts
static clearPool(objectConstructor: typeof BaseObject): void;

定义于: core/BaseObject.ts:111

清除特定对象池的缓存实例。

参数 ​

参数类型默认值描述
objectConstructortypeof BaseObjectnull特定的类。 (不设置则清除所有缓存的实例)

返回 ​

void

继承自 ​

BaseObject.clearPool


setMaxCount() ​

ts
static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;

定义于: core/BaseObject.ts:72

设置特定对象池的最大缓存数量。

参数 ​

参数类型描述
objectConstructortypeof BaseObject特定的类。 (不设置则设置所有对象池的最大缓存数量)
maxCountnumber最大缓存数量。

返回 ​

void

继承自 ​

BaseObject.setMaxCount


toString() ​

ts
static toString(): string;

定义于: armature/Armature.ts:45

返回 ​

string

重写了 ​

BaseObject.toString

Released under the MIT License.