Skip to content

API / Slot

Class: abstract Slot

Defined in: armature/Slot.ts:167

The slot attached to the armature, controls the display status and properties of the display object. A bone can contain multiple slots. A slot can contain multiple display objects, displaying only one of the display objects at a time, but you can toggle the display object into frame animation while the animation is playing. The display object can be a normal texture, or it can be a display of a child armature, a grid display object, and a custom other display object.

Extends

Extended by

Constructors

Constructor

ts
new Slot(): Slot;

Returns

Slot

Inherited from

TransformObject.constructor

Properties

_alpha

ts
_alpha: number;

Defined in: armature/TransformObject.ts:78

Internal

Inherited from

TransformObject._alpha


_armature

ts
_armature: Armature;

Defined in: armature/TransformObject.ts:86

Internal

Inherited from

TransformObject._armature


_cachedFrameIndices

ts
_cachedFrameIndices: number[];

Defined in: armature/Slot.ts:255

Internal


_colorDirty

ts
_colorDirty: boolean;

Defined in: armature/Slot.ts:190

Internal


_colorTransform

ts
readonly _colorTransform: ColorTransform;

Defined in: armature/Slot.ts:221

Internal


_displayFrame

ts
_displayFrame: DisplayFrame;

Defined in: armature/Slot.ts:237

Internal


_displayFrames

ts
readonly _displayFrames: DisplayFrame[] = [];

Defined in: armature/Slot.ts:225

Internal


_geometryBones

ts
readonly _geometryBones: Bone[] = [];

Defined in: armature/Slot.ts:229

Internal


_geometryData

ts
_geometryData: GeometryData;

Defined in: armature/Slot.ts:241

Internal


_globalAlpha

ts
_globalAlpha: number;

Defined in: armature/TransformObject.ts:82

Internal

Inherited from

TransformObject._globalAlpha


_pivotX

ts
_pivotX: number;

Defined in: armature/Slot.ts:212

Internal


_pivotY

ts
_pivotY: number;

Defined in: armature/Slot.ts:216

Internal


_slotData

ts
_slotData: SlotData;

Defined in: armature/Slot.ts:233

Internal


_verticesDirty

ts
_verticesDirty: boolean;

Defined in: armature/Slot.ts:194

Internal


_zIndex

ts
_zIndex: number;

Defined in: armature/Slot.ts:208

Internal


_zOrder

ts
_zOrder: number;

Defined in: armature/Slot.ts:204

Internal


displayController

ts
displayController: string;

Defined in: armature/Slot.ts:179

Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states.

Default

ts
null

global

ts
readonly global: Transform;

Defined in: armature/TransformObject.ts:56

A transform relative to the armature coordinate system.

Inherited from

TransformObject.global


globalTransformMatrix

ts
readonly globalTransformMatrix: Matrix;

Defined in: armature/TransformObject.ts:47

A matrix relative to the armature coordinate system.

Inherited from

TransformObject.globalTransformMatrix


hashCode

ts
readonly hashCode: number;

Defined in: core/BaseObject.ts:156

A unique identification number assigned to the object.

Inherited from

TransformObject.hashCode


offset

ts
readonly offset: Transform;

Defined in: armature/TransformObject.ts:65

The offset transform relative to the armature or the parent bone coordinate system.

Inherited from

TransformObject.offset

Accessors

armature

Get Signature

ts
get armature(): Armature;

Defined in: armature/TransformObject.ts:129

The armature to which it belongs.

Returns

Armature

Inherited from

TransformObject.armature


boundingBoxData

Get Signature

ts
get boundingBoxData(): BoundingBoxData;

Defined in: armature/Slot.ts:1156

The custom bounding box data for the slot at current time.

Returns

BoundingBoxData


childArmature

Get Signature

ts
get childArmature(): Armature;

Defined in: armature/Slot.ts:1215

The child armature that the slot displayed at current time.

Example
ts
    let slot = armature.getSlot("weapon");
    let prevChildArmature = slot.childArmature;
    if (prevChildArmature) {
        prevChildArmature.dispose();
    }
    slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
Returns

Armature

Set Signature

ts
set childArmature(value: Armature): void;

Defined in: armature/Slot.ts:1218

Parameters
ParameterType
valueArmature
Returns

void


display

Get Signature

ts
get display(): any;

Defined in: armature/Slot.ts:1183

The display object that the slot displays at this time.

Example
ts
    let slot = armature.getSlot("text");
    slot.display = new yourEngine.TextField();
Returns

any

Set Signature

ts
set display(value: any): void;

Defined in: armature/Slot.ts:1186

Parameters
ParameterType
valueany
Returns

void


displayFrameCount

Set Signature

ts
set displayFrameCount(value: number): void;

Defined in: armature/Slot.ts:1067

Parameters
ParameterType
valuenumber
Returns

void


displayIndex

Get Signature

ts
get displayIndex(): number;

Defined in: armature/Slot.ts:1098

The index of the display object displayed in the display list.

Example
ts
    let slot = armature.getSlot("weapon");
    slot.displayIndex = 3;
    slot.displayController = "none";
Returns

number

Set Signature

ts
set displayIndex(value: number): void;

Defined in: armature/Slot.ts:1101

Parameters
ParameterType
valuenumber
Returns

void


displayList

Get Signature

ts
get displayList(): any[];

Defined in: armature/Slot.ts:1123

Contains a display list of display objects or child armatures.

Returns

any[]

Set Signature

ts
set displayList(value: any[]): void;

Defined in: armature/Slot.ts:1131

Parameters
ParameterType
valueany[]
Returns

void


name

Get Signature

ts
get name(): string;

Defined in: armature/Slot.ts:1113

The slot name.

Returns

string


parent

Get Signature

ts
get parent(): Bone;

Defined in: armature/Slot.ts:1232

The parent bone to which it belongs.

Returns

Bone


slotData

Get Signature

ts
get slotData(): SlotData;

Defined in: armature/Slot.ts:1146

The slot data.

Returns

SlotData


visible

Get Signature

ts
get visible(): boolean;

Defined in: armature/Slot.ts:1050

The visible of slot's display object.

Default
ts
true
Returns

boolean

Set Signature

ts
set visible(value: boolean): void;

Defined in: armature/Slot.ts:1053

Parameters
ParameterType
valueboolean
Returns

void

Methods

_isBonesUpdate()

ts
_isBonesUpdate(): boolean;

Defined in: armature/Slot.ts:358

Internal

Returns

boolean


_setColor()

ts
_setColor(value: ColorTransform): boolean;

Defined in: armature/Slot.ts:627

Internal

Parameters

ParameterType
valueColorTransform

Returns

boolean


_setDisplayIndex()

ts
_setDisplayIndex(value: number, isAnimation: boolean): void;

Defined in: armature/Slot.ts:594

Internal

Parameters

ParameterTypeDefault value
valuenumberundefined
isAnimationbooleanfalse

Returns

void


_setZOrder()

ts
_setZOrder(value: number): boolean;

Defined in: armature/Slot.ts:614

Internal

Parameters

ParameterType
valuenumber

Returns

boolean


_updateAlpha()

ts
_updateAlpha(): void;

Defined in: armature/Slot.ts:370

Internal

Returns

void


_updateVisible()

ts
abstract _updateVisible(): void;

Defined in: armature/Slot.ts:338

Internal

Returns

void


containsPoint()

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

Defined in: armature/Slot.ts:933

Check whether a specific point is inside a custom bounding box in the slot. The coordinate system of the point is the inner coordinate system of the armature. Custom bounding boxes need to be customized in Dragonbones Pro.

Parameters

ParameterTypeDescription
xnumberThe horizontal coordinate of the point.
ynumberThe vertical coordinate of the point.

Returns

boolean


getDisplay()

ts
getDisplay(): any;

Defined in: armature/Slot.ts:1243

Deprecated, please refer to #display.

Returns

any

Deprecated


init()

ts
init(
   slotData: SlotData, 
   armatureValue: Armature, 
   rawDisplay: any, 
   meshDisplay: any): void;

Defined in: armature/Slot.ts:635

Internal

Parameters

ParameterType
slotDataSlotData
armatureValueArmature
rawDisplayany
meshDisplayany

Returns

void


intersectsSegment()

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

Defined in: armature/Slot.ts:981

Check whether a specific segment intersects a custom bounding box for the slot. The coordinate system of the segment and intersection is the inner coordinate system of the armature. Custom bounding boxes need to be customized in Dragonbones Pro.

Parameters

ParameterTypeDefault valueDescription
xAnumberundefinedThe horizontal coordinate of the beginning of the segment.
yAnumberundefinedThe vertical coordinate of the beginning of the segment.
xBnumberundefinedThe horizontal coordinate of the end point of the segment.
yBnumberundefinedThe vertical coordinate of the end point of the segment.
intersectionPointA{ x: number; y: number; }nullThe first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated)
intersectionPointA.xnumberundefined-
intersectionPointA.ynumberundefined-
intersectionPointB{ x: number; y: number; }nullThe first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated)
intersectionPointB.xnumberundefined-
intersectionPointB.ynumberundefined-
normalRadians{ x: number; y: number; }nullThe normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated)
normalRadians.xnumberundefined-
normalRadians.ynumberundefined-

Returns

number

Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections]


invalidUpdate()

ts
invalidUpdate(): void;

Defined in: armature/Slot.ts:788

Forces the slot to update the state of the display object in the next frame.

Returns

void


returnToPool()

ts
returnToPool(): void;

Defined in: core/BaseObject.ts:167

Clear the object and return it back to object pool。

Returns

void

Inherited from

TransformObject.returnToPool


setDisplay()

ts
setDisplay(value: any): void;

Defined in: armature/Slot.ts:1253

Deprecated, please refer to #display.

Parameters

ParameterType
valueany

Returns

void

Deprecated


update()

ts
update(cacheFrameIndex: number): void;

Defined in: armature/Slot.ts:674

Internal

Parameters

ParameterType
cacheFrameIndexnumber

Returns

void


updateGlobalTransform()

ts
updateGlobalTransform(): void;

Defined in: armature/TransformObject.ts:116

For performance considerations, rotation or scale in the #global attribute of the bone or slot is not always properly accessible, some engines do not rely on these attributes to update rendering, such as Egret. The use of this method ensures that the access to the #global property is correctly rotation or scale.

Returns

void

Example

ts
    bone.updateGlobalTransform();
    let rotation = bone.global.rotation;

Inherited from

TransformObject.updateGlobalTransform


borrowObject()

ts
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

ParameterTypeDescription
objectConstructor() => TThe specify class.

Returns

T

Inherited from

TransformObject.borrowObject


clearPool()

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

Defined in: core/BaseObject.ts:111

Clear the cached instances of a specify object pool.

Parameters

ParameterTypeDefault valueDescription
objectConstructortypeof BaseObjectnullSpecify class. (Clear all cached instances if not set)

Returns

void

Inherited from

TransformObject.clearPool


setMaxCount()

ts
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

ParameterTypeDescription
objectConstructortypeof BaseObjectThe specify class. (Set all object pools max cache count if not set)
maxCountnumberMax count.

Returns

void

Inherited from

TransformObject.setMaxCount


toString()

ts
static toString(): string;

Defined in: core/BaseObject.ts:56

Returns

string

Inherited from

TransformObject.toString

Released under the MIT License.