UNPKG

dragonbones-pixijs

Version:
292 lines (291 loc) 13.5 kB
import { WorldClock } from "../animation/WorldClock"; import { Armature } from "../armature/Armature"; import { Slot } from "../armature/Slot"; import { DragonBones, Map } from "../core/DragonBones"; import { ArmatureData, SlotData } from "../model/ArmatureData"; import { DisplayData, ArmatureDisplayData } from "../model/DisplayData"; import { DragonBonesData } from "../model/DragonBonesData"; import { SkinData } from "../model/SkinData"; import { TextureAtlasData, TextureData } from "../model/TextureAtlasData"; import { BinaryDataParser } from "../parser/BinaryDataParser"; import { DataParser } from "../parser/DataParser"; import { ObjectDataParser } from "../parser/ObjectDataParser"; /** * - 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. * @see dragonBones.DragonBonesData * @see dragonBones.TextureAtlasData * @see dragonBones.ArmatureData * @see dragonBones.Armature * @version DragonBones 3.0 * @language en_US */ export declare abstract class BaseFactory { protected static _objectParser: ObjectDataParser; protected static _binaryParser: BinaryDataParser; /** * @private */ autoSearch: boolean; protected readonly _dragonBonesDataMap: Map<DragonBonesData>; protected readonly _textureAtlasDataMap: Map<Array<TextureAtlasData>>; protected _dragonBones: DragonBones; protected _dataParser: DataParser; /** * - Create a factory instance. (typically only one global factory instance is required) * @version DragonBones 3.0 * @language en_US */ constructor(dataParser?: DataParser | null); protected _isSupportMesh(): boolean; protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; /** * @private */ protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, _slot: Slot, displayData: ArmatureDisplayData): Armature | null; protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, slot: Slot): any; protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; /** * - Parse the raw data to a DragonBonesData instance and cache it to the factory. * @param rawData - The raw data. * @param name - 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) * @param scale - Specify a scaling value for all armatures. (Default: 1.0) * @returns DragonBonesData instance * @see #getDragonBonesData() * @see #addDragonBonesData() * @see #removeDragonBonesData() * @see dragonBones.DragonBonesData * @version DragonBones 4.5 * @language en_US */ parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; /** * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. * @param rawData - The raw texture atlas data. * @param textureAtlas - The texture atlas object. * @param name - 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) * @param scale - Specify a scaling value for the map set. (Default: 1.0) * @returns TextureAtlasData instance * @see #getTextureAtlasData() * @see #addTextureAtlasData() * @see #removeTextureAtlasData() * @see dragonBones.TextureAtlasData * @version DragonBones 4.5 * @language en_US */ parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; /** * - Update texture atlases. * @param textureAtlases - The texture atlas objects. * @param name - The texture atlas name. * @version DragonBones 5.7 * @language en_US */ updateTextureAtlases(textureAtlases: Array<any>, name: string): void; /** * - Get a specific DragonBonesData instance. * @param name - The DragonBonesData instance cache name. * @returns DragonBonesData instance * @see #parseDragonBonesData() * @see #addDragonBonesData() * @see #removeDragonBonesData() * @see dragonBones.DragonBonesData * @version DragonBones 3.0 * @language en_US */ getDragonBonesData(name: string): DragonBonesData | null; /** * - Cache a DragonBonesData instance to the factory. * @param data - The DragonBonesData instance. * @param name - 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) * @see #parseDragonBonesData() * @see #getDragonBonesData() * @see #removeDragonBonesData() * @see dragonBones.DragonBonesData * @version DragonBones 3.0 * @language en_US */ addDragonBonesData(data: DragonBonesData, name?: string | null): void; /** * - Remove a DragonBonesData instance. * @param name - The DragonBonesData instance cache name. * @param disposeData - Whether to dispose data. (Default: true) * @see #parseDragonBonesData() * @see #getDragonBonesData() * @see #addDragonBonesData() * @see dragonBones.DragonBonesData * @version DragonBones 3.0 * @language en_US */ removeDragonBonesData(name: string, disposeData?: boolean): void; /** * - Get a list of specific TextureAtlasData instances. * @param name - The TextureAtlasData cahce name. * @see #parseTextureAtlasData() * @see #addTextureAtlasData() * @see #removeTextureAtlasData() * @see dragonBones.TextureAtlasData * @version DragonBones 3.0 * @language en_US */ getTextureAtlasData(name: string): Array<TextureAtlasData> | null; /** * - Cache a TextureAtlasData instance to the factory. * @param data - The TextureAtlasData instance. * @param name - 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) * @see #parseTextureAtlasData() * @see #getTextureAtlasData() * @see #removeTextureAtlasData() * @see dragonBones.TextureAtlasData * @version DragonBones 3.0 * @language en_US */ addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; /** * - Remove a TextureAtlasData instance. * @param name - The TextureAtlasData instance cache name. * @param disposeData - Whether to dispose data. * @see #parseTextureAtlasData() * @see #getTextureAtlasData() * @see #addTextureAtlasData() * @see dragonBones.TextureAtlasData * @version DragonBones 3.0 * @language en_US */ removeTextureAtlasData(name: string, disposeData?: boolean): void; /** * - Get a specific armature data. * @param name - The armature data name. * @param dragonBonesName - The cached name for DragonbonesData instance. * @see dragonBones.ArmatureData * @version DragonBones 5.1 * @language en_US */ getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; /** * - Clear all cached DragonBonesData instances and TextureAtlasData instances. * @param disposeData - Whether to dispose data. * @version DragonBones 4.5 * @language en_US */ clear(disposeData?: boolean): void; /** * - 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 {@link #dragonBones.Armature#dispose()}. * @param armatureName - The armature data name. * @param dragonBonesName - 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) * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) * @returns The armature. * @example * <pre> * let armature = factory.buildArmature("armatureName", "dragonBonesName"); * armature.clock = factory.clock; * </pre> * @see dragonBones.DragonBonesData * @see dragonBones.ArmatureData * @version DragonBones 3.0 * @language en_US */ buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; /** * @private */ replaceDisplay(slot: Slot, displayData: DisplayData | null, displayIndex?: number): void; /** * - Replaces the current display data for a particular slot with a specific display data. * Specify display data with "dragonBonesName/armatureName/slotName/displayName". * @param dragonBonesName - The DragonBonesData instance cache name. * @param armatureName - The armature data name. * @param slotName - The slot data name. * @param displayName - The display data name. * @param slot - The slot. * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) * @example * <pre> * let slot = armature.getSlot("weapon"); * factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot); * </pre> * @version DragonBones 4.5 * @language en_US */ replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; /** * @private */ replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; /** * - Share specific skin data with specific armature. * @param armature - The armature. * @param skin - The skin data. * @param isOverride - Whether it completely override the original skin. (Default: false) * @param exclude - A list of slot names that do not need to be replace. * @example * <pre> * 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"]); * } * </pre> * @see dragonBones.Armature * @see dragonBones.SkinData * @version DragonBones 5.6 * @language en_US */ replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array<string> | null): boolean; /** * - 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. * @param armature - The armtaure. * @param armatureData - The armature data. * @param isOverride - Whether to completely overwrite the original animation. (Default: false) * @example * <pre> * let armatureA = factory.buildArmature("armatureA", "dragonBonesA"); * let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB"); * if (armatureDataB) { * factory.replaceAnimation(armatureA, armatureDataB); * } * </pre> * @see dragonBones.Armature * @see dragonBones.ArmatureData * @version DragonBones 5.6 * @language en_US */ replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; /** * @private */ getAllDragonBonesData(): Map<DragonBonesData>; /** * @private */ getAllTextureAtlasData(): Map<Array<TextureAtlasData>>; /** * - An Worldclock instance updated by engine. * @version DragonBones 5.7 * @language en_US */ get clock(): WorldClock; /** * @private */ get dragonBones(): DragonBones; } /** * @private */ export declare class BuildArmaturePackage { dataName: string; textureAtlasName: string; data: DragonBonesData; armature: ArmatureData; skin: SkinData | null; }