Skip to content

API / PixiFactory

Class: PixiFactory

Defined in: pixi/PixiFactory.ts:43

The PixiJS factory.

Extends

Constructors

Constructor

ts
new PixiFactory(dataParser: DataParser, useSharedTicker: boolean): PixiFactory;

Defined in: pixi/PixiFactory.ts:96

Parameters

ParameterTypeDefault value
dataParserDataParsernull
useSharedTickerbooleantrue

Returns

PixiFactory

Inherit Doc

Overrides

BaseFactory.constructor

Properties

useSharedTicker

ts
static useSharedTicker: boolean = true;

Defined in: pixi/PixiFactory.ts:63

whether use PIXI.Ticker.shared

Accessors

clock

Get Signature

ts
get clock(): WorldClock;

Defined in: factory/BaseFactory.ts:933

An Worldclock instance updated by engine.

Returns

WorldClock

Inherited from

BaseFactory.clock


soundEventManager

Get Signature

ts
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

PixiArmatureDisplay


factory

Get Signature

ts
get static factory(): PixiFactory;

Defined in: pixi/PixiFactory.ts:72

A global factory instance that can be used directly.

Returns

PixiFactory

Methods

addDragonBonesData()

ts
addDragonBonesData(data: DragonBonesData, name: string): void;

Defined in: factory/BaseFactory.ts:462

Cache a DragonBonesData instance to the factory.

Parameters

ParameterTypeDefault valueDescription
dataDragonBonesDataundefinedThe DragonBonesData instance.
namestringnullSpecify 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()

ts
addTextureAtlasData(data: TextureAtlasData, name: string): void;

Defined in: factory/BaseFactory.ts:535

Cache a TextureAtlasData instance to the factory.

Parameters

ParameterTypeDefault valueDescription
dataTextureAtlasDataundefinedThe TextureAtlasData instance.
namestringnullSpecify 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()

ts
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

ParameterTypeDefault valueDescription
armatureNamestringundefinedThe armature data name.
dragonBonesNamestring""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)
skinNamestring""The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
textureAtlasNamestring""-

Returns

Armature

The armature.

Example

ts
    let armature = factory.buildArmature("armatureName", "dragonBonesName");
    armature.clock = factory.clock;

Inherited from

BaseFactory.buildArmature


buildArmatureDisplay()

ts
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

ParameterTypeDefault valueDescription
armatureNamestringundefinedThe armature data name.
dragonBonesNamestring""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)
skinNamestring""The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data)
textureAtlasNamestring""-

Returns

PixiArmatureDisplay

The armature display container.

Example

ts
    let armatureDisplay = factory.buildArmatureDisplay("armatureName", "dragonBonesName");

clear()

ts
clear(disposeData: boolean): void;

Defined in: factory/BaseFactory.ts:603

Clear all cached DragonBonesData instances and TextureAtlasData instances.

Parameters

ParameterTypeDefault valueDescription
disposeDatabooleantrueWhether to dispose data.

Returns

void

Inherited from

BaseFactory.clear


getArmatureData()

ts
getArmatureData(name: string, dragonBonesName: string): ArmatureData;

Defined in: factory/BaseFactory.ts:585

Get a specific armature data.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe armature data name.
dragonBonesNamestring""The cached name for DragonbonesData instance.

Returns

ArmatureData

Inherited from

BaseFactory.getArmatureData


getDragonBonesData()

ts
getDragonBonesData(name: string): DragonBonesData;

Defined in: factory/BaseFactory.ts:442

Get a specific DragonBonesData instance.

Parameters

ParameterTypeDescription
namestringThe DragonBonesData instance cache name.

Returns

DragonBonesData

DragonBonesData instance

Inherited from

BaseFactory.getDragonBonesData


getTextureAtlasData()

ts
getTextureAtlasData(name: string): TextureAtlasData[];

Defined in: factory/BaseFactory.ts:515

Get a list of specific TextureAtlasData instances.

Parameters

ParameterTypeDescription
namestringThe TextureAtlasData cahce name.

Returns

TextureAtlasData[]

Inherited from

BaseFactory.getTextureAtlasData


getTextureDisplay()

ts
getTextureDisplay(textureName: string, textureAtlasName: string): Sprite;

Defined in: pixi/PixiFactory.ts:195

Create the display object with the specified texture.

Parameters

ParameterTypeDefault valueDescription
textureNamestringundefinedThe texture data name.
textureAtlasNamestringnullThe texture atlas data name (Of not set, all texture atlas data will be searched)

Returns

Sprite


parseDragonBonesData()

ts
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

ParameterTypeDefault valueDescription
rawDatastring | ObjectundefinedThe raw data.
namestringnullSpecify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead)
scalenumber1.0Specify a scaling value for all armatures. (Default: 1.0)

Returns

DragonBonesData

DragonBonesData instance

Overrides

BaseFactory.parseDragonBonesData


parseTextureAtlasData()

ts
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

ParameterTypeDefault valueDescription
rawDatastring | ObjectundefinedThe raw texture atlas data.
textureAtlas?string | Texture<TextureSource<any>>undefinedThe texture atlas object.
name?stringnullSpecify 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?number1.0Specify a scaling value for the map set. (Default: 1.0)

Returns

TextureAtlasData

TextureAtlasData instance

Example

ts
const factory = PixiFactory.factory;
factory.parseTextureAtlasData("preload/starter_tex.json");

Overrides

BaseFactory.parseTextureAtlasData


removeDragonBonesData()

ts
removeDragonBonesData(name: string, disposeData: boolean): void;

Defined in: factory/BaseFactory.ts:492

Remove a DragonBonesData instance.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe DragonBonesData instance cache name.
disposeDatabooleantrueWhether to dispose data. (Default: true)

Returns

void

Inherited from

BaseFactory.removeDragonBonesData


removeTextureAtlasData()

ts
removeTextureAtlasData(name: string, disposeData: boolean): void;

Defined in: factory/BaseFactory.ts:559

Remove a TextureAtlasData instance.

Parameters

ParameterTypeDefault valueDescription
namestringundefinedThe TextureAtlasData instance cache name.
disposeDatabooleantrueWhether to dispose data.

Returns

void

Inherited from

BaseFactory.removeTextureAtlasData


replaceAnimation()

ts
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

ParameterTypeDefault valueDescription
armatureArmatureundefinedThe armtaure.
armatureDataArmatureDataundefinedThe armature data.
isOverridebooleantrueWhether to completely overwrite the original animation. (Default: false)

Returns

boolean

Example

ts
    let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
    let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
    if (armatureDataB) {
    factory.replaceAnimation(armatureA, armatureDataB);
    }

Inherited from

BaseFactory.replaceAnimation


replaceSkin()

ts
replaceSkin(
   armature: Armature, 
   skin: SkinData, 
   isOverride: boolean, 
   exclude: string[]): boolean;

Defined in: factory/BaseFactory.ts:799

Share specific skin data with specific armature.

Parameters

ParameterTypeDefault valueDescription
armatureArmatureundefinedThe armature.
skinSkinDataundefinedThe skin data.
isOverridebooleanfalseWhether it completely override the original skin. (Default: false)
excludestring[]nullA list of slot names that do not need to be replace.

Returns

boolean

Example

ts
    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

BaseFactory.replaceSkin


replaceSlotDisplay()

ts
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

ParameterTypeDefault valueDescription
dragonBonesNamestringundefinedThe DragonBonesData instance cache name.
armatureNamestringundefinedThe armature data name.
slotNamestringundefinedThe slot data name.
displayNamestringundefinedThe display data name.
slotSlotundefinedThe slot.
displayIndexnumber-1The index of the display data that is replaced. (If it is not set, replaces the current display data)

Returns

boolean

Example

ts
    let slot = armature.getSlot("weapon");
    factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);

Inherited from

BaseFactory.replaceSlotDisplay


updateTextureAtlases()

ts
updateTextureAtlases(textureAtlases: any[], name: string): void;

Defined in: factory/BaseFactory.ts:415

Update texture atlases.

Parameters

ParameterTypeDescription
textureAtlasesany[]The texture atlas objects.
namestringThe texture atlas name.

Returns

void

Inherited from

BaseFactory.updateTextureAtlases


advanceTime()

ts
static advanceTime(passedTime: number): void;

Defined in: pixi/PixiFactory.ts:54

passedTime is elapsed time, specified in seconds.

Parameters

ParameterType
passedTimenumber

Returns

void


newInstance()

ts
static newInstance(useSharedTicker: boolean): PixiFactory;

Defined in: pixi/PixiFactory.ts:85

  • 一个获取全局工厂实例(单例)的方法, 和get factory相比, 优点是可以传参数。

Parameters

ParameterTypeDefault value
useSharedTickerbooleantrue

Returns

PixiFactory

Released under the MIT License.