API / PixiFactory
Class: PixiFactory
Defined in: pixi/PixiFactory.ts:43
The PixiJS factory.
Extends
Constructors
Constructor
new PixiFactory(dataParser: DataParser, useSharedTicker: boolean): PixiFactory;
Defined in: pixi/PixiFactory.ts:96
Parameters
Parameter | Type | Default value |
---|---|---|
dataParser | DataParser | null |
useSharedTicker | boolean | true |
Returns
PixiFactory
Inherit Doc
Overrides
Properties
useSharedTicker
static useSharedTicker: boolean = true;
Defined in: pixi/PixiFactory.ts:63
whether use PIXI.Ticker.shared
Accessors
clock
Get Signature
get clock(): WorldClock;
Defined in: factory/BaseFactory.ts:933
An Worldclock instance updated by engine.
Returns
Inherited from
soundEventManager
Get Signature
get soundEventManager(): PixiArmatureDisplay;
Defined in: pixi/PixiFactory.ts:213
A global sound event manager. Sound events can be listened to uniformly from the manager.
Returns
factory
Get Signature
get static factory(): PixiFactory;
Defined in: pixi/PixiFactory.ts:72
A global factory instance that can be used directly.
Returns
PixiFactory
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
Inherited from
BaseFactory
.addDragonBonesData
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
Inherited from
BaseFactory
.addTextureAtlasData
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;
Inherited from
buildArmatureDisplay()
buildArmatureDisplay(
armatureName: string,
dragonBonesName: string,
skinName: string,
textureAtlasName: string): PixiArmatureDisplay;
Defined in: pixi/PixiFactory.ts:171
Create a armature from cached DragonBonesData instances and TextureAtlasData instances, then use the #clock to update it. The difference is that the armature created by #buildArmature is not WorldClock instance update.
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 display container.
Example
let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");
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
Inherited from
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
Inherited from
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
Inherited from
BaseFactory
.getDragonBonesData
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
Inherited from
BaseFactory
.getTextureAtlasData
getTextureDisplay()
getTextureDisplay(textureName: string, textureAtlasName: string): Sprite;
Defined in: pixi/PixiFactory.ts:195
Create the display object with the specified texture.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
textureName | string | undefined | The texture data name. |
textureAtlasName | string | null | The texture atlas data name (Of not set, all texture atlas data will be searched) |
Returns
Sprite
parseDragonBonesData()
parseDragonBonesData(
rawData: string | Object,
name: string,
scale: number): DragonBonesData;
Defined in: pixi/PixiFactory.ts:240
Parse the raw data to a DragonBonesData instance and cache it to the factory.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
rawData | string | Object | 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
Overrides
BaseFactory
.parseDragonBonesData
parseTextureAtlasData()
parseTextureAtlasData(
rawData: string | Object,
textureAtlas?: string | Texture<TextureSource<any>>,
name?: string,
scale?: number): TextureAtlasData;
Defined in: pixi/PixiFactory.ts:283
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 | string | Object | undefined | The raw texture atlas data. |
textureAtlas? | string | Texture <TextureSource <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
Example
const factory = PixiFactory.factory;
factory.parseTextureAtlasData("preload/starter_tex.json");
Overrides
BaseFactory
.parseTextureAtlasData
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
Inherited from
BaseFactory
.removeDragonBonesData
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
Inherited from
BaseFactory
.removeTextureAtlasData
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);
}
Inherited from
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"]);
}
Inherited from
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);
Inherited from
BaseFactory
.replaceSlotDisplay
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
Inherited from
BaseFactory
.updateTextureAtlases
advanceTime()
static advanceTime(passedTime: number): void;
Defined in: pixi/PixiFactory.ts:54
passedTime
is elapsed time, specified in seconds.
Parameters
Parameter | Type |
---|---|
passedTime | number |
Returns
void
newInstance()
static newInstance(useSharedTicker: boolean): PixiFactory;
Defined in: pixi/PixiFactory.ts:85
- 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。
Parameters
Parameter | Type | Default value |
---|---|---|
useSharedTicker | boolean | true |
Returns
PixiFactory