API / BaseFactory
Class: abstract
BaseFactory
Defined in: factory/BaseFactory.ts:46
Base class for the factory that create the armatures. (Typically only one global factory instance is required) The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance.
Extended by
Constructors
Constructor
new BaseFactory(dataParser: DataParser): BaseFactory;
Defined in: factory/BaseFactory.ts:65
Create a factory instance. (typically only one global factory instance is required)
Parameters
Parameter | Type | Default value |
---|---|---|
dataParser | DataParser | null |
Returns
BaseFactory
Accessors
clock
Get Signature
get clock(): WorldClock;
Defined in: factory/BaseFactory.ts:933
An Worldclock instance updated by engine.
Returns
Methods
addDragonBonesData()
addDragonBonesData(data: DragonBonesData, name: string): void;
Defined in: factory/BaseFactory.ts:462
Cache a DragonBonesData instance to the factory.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
data | DragonBonesData | undefined | The DragonBonesData instance. |
name | string | null | Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) |
Returns
void
addTextureAtlasData()
addTextureAtlasData(data: TextureAtlasData, name: string): void;
Defined in: factory/BaseFactory.ts:535
Cache a TextureAtlasData instance to the factory.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
data | TextureAtlasData | undefined | The TextureAtlasData instance. |
name | string | null | Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) |
Returns
void
buildArmature()
buildArmature(
armatureName: string,
dragonBonesName: string,
skinName: string,
textureAtlasName: string): Armature;
Defined in: factory/BaseFactory.ts:651
Create a armature from cached DragonBonesData instances and TextureAtlasData instances. Note that when the created armature that is no longer in use, you need to explicitly dispose Armature#dispose().
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
armatureName | string | undefined | The armature data name. |
dragonBonesName | string | "" | The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) |
skinName | string | "" | The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) |
textureAtlasName | string | "" | - |
Returns
The armature.
Example
let armature = factory.buildArmature("armatureName", "dragonBonesName");
armature.clock = factory.clock;
clear()
clear(disposeData: boolean): void;
Defined in: factory/BaseFactory.ts:603
Clear all cached DragonBonesData instances and TextureAtlasData instances.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
disposeData | boolean | true | Whether to dispose data. |
Returns
void
getArmatureData()
getArmatureData(name: string, dragonBonesName: string): ArmatureData;
Defined in: factory/BaseFactory.ts:585
Get a specific armature data.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
name | string | undefined | The armature data name. |
dragonBonesName | string | "" | The cached name for DragonbonesData instance. |
Returns
getDragonBonesData()
getDragonBonesData(name: string): DragonBonesData;
Defined in: factory/BaseFactory.ts:442
Get a specific DragonBonesData instance.
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The DragonBonesData instance cache name. |
Returns
DragonBonesData instance
getTextureAtlasData()
getTextureAtlasData(name: string): TextureAtlasData[];
Defined in: factory/BaseFactory.ts:515
Get a list of specific TextureAtlasData instances.
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The TextureAtlasData cahce name. |
Returns
parseDragonBonesData()
parseDragonBonesData(
rawData: any,
name: string,
scale: number): DragonBonesData;
Defined in: factory/BaseFactory.ts:347
Parse the raw data to a DragonBonesData instance and cache it to the factory.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
rawData | any | undefined | The raw data. |
name | string | null | Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) |
scale | number | 1.0 | Specify a scaling value for all armatures. (Default: 1.0) |
Returns
DragonBonesData instance
parseTextureAtlasData()
parseTextureAtlasData(
rawData: any,
textureAtlas: any,
name: string,
scale: number): TextureAtlasData;
Defined in: factory/BaseFactory.ts:394
Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
rawData | any | undefined | The raw texture atlas data. |
textureAtlas | any | undefined | The texture atlas object. |
name | string | null | Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) |
scale | number | 1.0 | Specify a scaling value for the map set. (Default: 1.0) |
Returns
TextureAtlasData instance
removeDragonBonesData()
removeDragonBonesData(name: string, disposeData: boolean): void;
Defined in: factory/BaseFactory.ts:492
Remove a DragonBonesData instance.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
name | string | undefined | The DragonBonesData instance cache name. |
disposeData | boolean | true | Whether to dispose data. (Default: true) |
Returns
void
removeTextureAtlasData()
removeTextureAtlasData(name: string, disposeData: boolean): void;
Defined in: factory/BaseFactory.ts:559
Remove a TextureAtlasData instance.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
name | string | undefined | The TextureAtlasData instance cache name. |
disposeData | boolean | true | Whether to dispose data. |
Returns
void
replaceAnimation()
replaceAnimation(
armature: Armature,
armatureData: ArmatureData,
isOverride: boolean): boolean;
Defined in: factory/BaseFactory.ts:868
Replaces the existing animation data for a specific armature with the animation data for the specific armature data. This enables you to make a armature template so that other armature without animations can share it's animations.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
armature | Armature | undefined | The armtaure. |
armatureData | ArmatureData | undefined | The armature data. |
isOverride | boolean | true | Whether to completely overwrite the original animation. (Default: false) |
Returns
boolean
Example
let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
if (armatureDataB) {
factory.replaceAnimation(armatureA, armatureDataB);
}
replaceSkin()
replaceSkin(
armature: Armature,
skin: SkinData,
isOverride: boolean,
exclude: string[]): boolean;
Defined in: factory/BaseFactory.ts:799
Share specific skin data with specific armature.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
armature | Armature | undefined | The armature. |
skin | SkinData | undefined | The skin data. |
isOverride | boolean | false | Whether it completely override the original skin. (Default: false) |
exclude | string [] | null | A list of slot names that do not need to be replace. |
Returns
boolean
Example
let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
if (armatureDataB && armatureDataB.defaultSkin) {
factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
}
replaceSlotDisplay()
replaceSlotDisplay(
dragonBonesName: string,
armatureName: string,
slotName: string,
displayName: string,
slot: Slot,
displayIndex: number): boolean;
Defined in: factory/BaseFactory.ts:731
Replaces the current display data for a particular slot with a specific display data. Specify display data with "dragonBonesName/armatureName/slotName/displayName".
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
dragonBonesName | string | undefined | The DragonBonesData instance cache name. |
armatureName | string | undefined | The armature data name. |
slotName | string | undefined | The slot data name. |
displayName | string | undefined | The display data name. |
slot | Slot | undefined | The slot. |
displayIndex | number | -1 | The index of the display data that is replaced. (If it is not set, replaces the current display data) |
Returns
boolean
Example
let slot = armature.getSlot("weapon");
factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
updateTextureAtlases()
updateTextureAtlases(textureAtlases: any[], name: string): void;
Defined in: factory/BaseFactory.ts:415
Update texture atlases.
Parameters
Parameter | Type | Description |
---|---|---|
textureAtlases | any [] | The texture atlas objects. |
name | string | The texture atlas name. |
Returns
void