API / Slot
类: abstract
Slot
定义于: armature/Slot.ts:167
插槽附着在骨骼上,控制显示对象的显示状态和属性。 一个骨骼上可以包含多个插槽。 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。
继承
继承于
构造函数
构造函数
new Slot(): Slot;
返回
Slot
继承自
属性
_alpha
_alpha: number;
定义于: armature/TransformObject.ts:78
Internal
继承自
_armature
_armature: Armature;
定义于: armature/TransformObject.ts:86
Internal
继承自
_cachedFrameIndices
_cachedFrameIndices: number[];
定义于: armature/Slot.ts:255
Internal
_colorDirty
_colorDirty: boolean;
定义于: armature/Slot.ts:190
Internal
_colorTransform
readonly _colorTransform: ColorTransform;
定义于: armature/Slot.ts:221
Internal
_displayFrame
_displayFrame: DisplayFrame;
定义于: armature/Slot.ts:237
Internal
_displayFrames
readonly _displayFrames: DisplayFrame[] = [];
定义于: armature/Slot.ts:225
Internal
_geometryBones
readonly _geometryBones: Bone[] = [];
定义于: armature/Slot.ts:229
Internal
_geometryData
_geometryData: GeometryData;
定义于: armature/Slot.ts:241
Internal
_globalAlpha
_globalAlpha: number;
定义于: armature/TransformObject.ts:82
Internal
继承自
_pivotX
_pivotX: number;
定义于: armature/Slot.ts:212
Internal
_pivotY
_pivotY: number;
定义于: armature/Slot.ts:216
Internal
_slotData
_slotData: SlotData;
定义于: armature/Slot.ts:233
Internal
_verticesDirty
_verticesDirty: boolean;
定义于: armature/Slot.ts:194
Internal
_zIndex
_zIndex: number;
定义于: armature/Slot.ts:208
Internal
_zOrder
_zOrder: number;
定义于: armature/Slot.ts:204
Internal
displayController
displayController: string;
定义于: armature/Slot.ts:179
显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。
默认值
null
global
readonly global: Transform;
定义于: armature/TransformObject.ts:56
相对于骨架坐标系的变换。
继承自
globalTransformMatrix
readonly globalTransformMatrix: Matrix;
定义于: armature/TransformObject.ts:47
相对于骨架坐标系的矩阵。
继承自
TransformObject
.globalTransformMatrix
hashCode
readonly hashCode: number;
分配给此实例的唯一标识号。
继承自
offset
readonly offset: Transform;
定义于: armature/TransformObject.ts:65
相对于骨架或父骨骼坐标系的偏移变换。
继承自
访问器
armature
Getter 签名
get armature(): Armature;
定义于: armature/TransformObject.ts:129
所属的骨架。
返回
继承自
boundingBoxData
Getter 签名
get boundingBoxData(): BoundingBoxData;
插槽此时的自定义包围盒数据。
返回
childArmature
Getter 签名
get childArmature(): Armature;
插槽此时显示的子骨架。 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。
示例
let slot = armature.getSlot("weapon");
let prevChildArmature = slot.childArmature;
if (prevChildArmature) {
prevChildArmature.dispose();
}
slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
返回
Setter 签名
set childArmature(value: Armature): void;
参数
参数 | 类型 |
---|---|
value | Armature |
返回
void
display
Getter 签名
get display(): any;
插槽此时显示的显示对象。
示例
let slot = armature.getSlot("text");
slot.display = new yourEngine.TextField();
返回
any
Setter 签名
set display(value: any): void;
参数
参数 | 类型 |
---|---|
value | any |
返回
void
displayFrameCount
Setter 签名
set displayFrameCount(value: number): void;
参数
参数 | 类型 |
---|---|
value | number |
返回
void
displayIndex
Getter 签名
get displayIndex(): number;
此时显示的显示对象在显示列表中的索引。
示例
let slot = armature.getSlot("weapon");
slot.displayIndex = 3;
slot.displayController = "none";
返回
number
Setter 签名
set displayIndex(value: number): void;
参数
参数 | 类型 |
---|---|
value | number |
返回
void
displayList
Getter 签名
get displayList(): any[];
包含显示对象或子骨架的显示列表。
返回
any
[]
Setter 签名
set displayList(value: any[]): void;
参数
参数 | 类型 |
---|---|
value | any [] |
返回
void
name
Getter 签名
get name(): string;
插槽名称。
返回
string
parent
Getter 签名
get parent(): Bone;
所属的父骨骼。
返回
slotData
Getter 签名
get slotData(): SlotData;
插槽数据。
返回
visible
Getter 签名
get visible(): boolean;
插槽的显示对象的可见。
默认值
true
返回
boolean
Setter 签名
set visible(value: boolean): void;
参数
参数 | 类型 |
---|---|
value | boolean |
返回
void
方法
_isBonesUpdate()
_isBonesUpdate(): boolean;
定义于: armature/Slot.ts:358
Internal
返回
boolean
_setColor()
_setColor(value: ColorTransform): boolean;
定义于: armature/Slot.ts:627
Internal
参数
参数 | 类型 |
---|---|
value | ColorTransform |
返回
boolean
_setDisplayIndex()
_setDisplayIndex(value: number, isAnimation: boolean): void;
定义于: armature/Slot.ts:594
Internal
参数
参数 | 类型 | 默认值 |
---|---|---|
value | number | undefined |
isAnimation | boolean | false |
返回
void
_setZOrder()
_setZOrder(value: number): boolean;
定义于: armature/Slot.ts:614
Internal
参数
参数 | 类型 |
---|---|
value | number |
返回
boolean
_updateAlpha()
_updateAlpha(): void;
定义于: armature/Slot.ts:370
Internal
返回
void
_updateVisible()
abstract _updateVisible(): void;
定义于: armature/Slot.ts:338
Internal
返回
void
containsPoint()
containsPoint(x: number, y: number): boolean;
定义于: armature/Slot.ts:933
检查特定点是否在插槽的自定义边界框内。 点的坐标系为骨架内坐标系。 自定义边界框需要在 DragonBones Pro 中自定义。
参数
参数 | 类型 | 描述 |
---|---|---|
x | number | 点的水平坐标。 |
y | number | 点的垂直坐标。 |
返回
boolean
getDisplay()
getDisplay(): any;
已废弃,请参考 #display。
返回
any
已被弃用
init()
init(
slotData: SlotData,
armatureValue: Armature,
rawDisplay: any,
meshDisplay: any): void;
定义于: armature/Slot.ts:635
Internal
参数
参数 | 类型 |
---|---|
slotData | SlotData |
armatureValue | Armature |
rawDisplay | any |
meshDisplay | any |
返回
void
intersectsSegment()
intersectsSegment(
xA: number,
yA: number,
xB: number,
yB: number,
intersectionPointA: object,
intersectionPointB: object,
normalRadians: object): number;
定义于: armature/Slot.ts:981
检查特定线段是否与插槽的自定义边界框相交。 线段和交点的坐标系均为骨架内坐标系。 自定义边界框需要在 DragonBones Pro 中自定义。
参数
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
xA | number | undefined | 线段起点的水平坐标。 |
yA | number | undefined | 线段起点的垂直坐标。 |
xB | number | undefined | 线段终点的水平坐标。 |
yB | number | undefined | 线段终点的垂直坐标。 |
intersectionPointA | { x : number ; y : number ; } | null | 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) |
intersectionPointA.x | number | undefined | - |
intersectionPointA.y | number | undefined | - |
intersectionPointB | { x : number ; y : number ; } | null | 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) |
intersectionPointB.x | number | undefined | - |
intersectionPointB.y | number | undefined | - |
normalRadians | { x : number ; y : number ; } | null | 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) |
normalRadians.x | number | undefined | - |
normalRadians.y | number | undefined | - |
返回
number
相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点]
invalidUpdate()
invalidUpdate(): void;
定义于: armature/Slot.ts:788
强制插槽在下一帧更新显示对象的状态。
返回
void
returnToPool()
returnToPool(): void;
清除该实例的所有数据并将其返还对象池。
返回
void
继承自
setDisplay()
setDisplay(value: any): void;
已废弃,请参考 #display。
参数
参数 | 类型 |
---|---|
value | any |
返回
void
已被弃用
update()
update(cacheFrameIndex: number): void;
定义于: armature/Slot.ts:674
Internal
参数
参数 | 类型 |
---|---|
cacheFrameIndex | number |
返回
void
updateGlobalTransform()
updateGlobalTransform(): void;
定义于: armature/TransformObject.ts:116
出于性能的考虑,骨骼或插槽的 #global 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 使用此方法可以保证访问到 #global 属性中正确的旋转或缩放。
返回
void
示例
bone.updateGlobalTransform();
let rotation = bone.global.rotation;
继承自
TransformObject
.updateGlobalTransform
borrowObject()
static borrowObject<T>(objectConstructor: () => T): T;
从对象池中获取特定类的实例。
类型参数
类型参数 |
---|
T extends BaseObject |
参数
参数 | 类型 | 描述 |
---|---|---|
objectConstructor | () => T | 特定的类。 |
返回
T
继承自
clearPool()
static clearPool(objectConstructor: typeof BaseObject): void;
清除特定对象池的缓存实例。
参数
参数 | 类型 | 默认值 | 描述 |
---|---|---|---|
objectConstructor | typeof BaseObject | null | 特定的类。 (不设置则清除所有缓存的实例) |
返回
void
继承自
setMaxCount()
static setMaxCount(objectConstructor: typeof BaseObject, maxCount: number): void;
设置特定对象池的最大缓存数量。
参数
参数 | 类型 | 描述 |
---|---|---|
objectConstructor | typeof BaseObject | 特定的类。 (不设置则设置所有对象池的最大缓存数量) |
maxCount | number | 最大缓存数量。 |
返回
void
继承自
toString()
static toString(): string;
返回
string