Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CCFactory

DragonBones factory

Hierarchy

  • BaseFactory
    • CCFactory

Implements

Index

Constructors

constructor

Properties

Private _dataParser

_dataParser: DataParser

Private _dragonBones

_dragonBones: DragonBones

Readonly Private _dragonBonesDataMap

_dragonBonesDataMap: Map<DragonBonesData>

Protected Optional _slots

_slots: CCSlot[]

Readonly Private _textureAtlasDataMap

_textureAtlasDataMap: Map<Array<TextureAtlasData>>

Private autoSearch

autoSearch: boolean

Readonly clock

clock: WorldClock
  • 由引擎驱动的 WorldClock 实例。
version

DragonBones 5.7

language

zh_CN

Readonly Private dragonBones

dragonBones: DragonBones

Optional id

id: undefined | string

Optional uuid

uuid: undefined | string

Static Private _binaryParser

_binaryParser: BinaryDataParser

Static _factory

_factory: CCFactory | null = null
method

getInstance

returns
static
example

let factory = CCFactory.getInstance();

Static Private _objectParser

_objectParser: ObjectDataParser

Methods

buildArmature

  • buildArmature(dataPackage: any): Armature

Private buildBones

  • buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void
  • Parameters

    • dataPackage: BuildArmaturePackage
    • armature: Armature

    Returns void

Private buildChildArmature

  • buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: DisplayData): Armature | null
  • Parameters

    • dataPackage: BuildArmaturePackage | null
    • slot: Slot
    • displayData: DisplayData

    Returns Armature | null

buildSlot

  • buildSlot(dataPackage: any, slotData: any, displays: any): CCSlot

Private buildSlots

  • buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void
  • Parameters

    • dataPackage: BuildArmaturePackage
    • armature: Armature

    Returns void

buildTextureAtlasData

Private fillBuildArmaturePackage

  • fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean
  • Parameters

    • dataPackage: BuildArmaturePackage
    • dragonBonesName: string
    • armatureName: string
    • skinName: string
    • textureAtlasName: string

    Returns boolean

Private getSlotDisplay

  • getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any
  • Parameters

    • dataPackage: BuildArmaturePackage | null
    • displayData: DisplayData
    • rawDisplayData: DisplayData | null
    • slot: Slot

    Returns any

Private getTextureData

  • getTextureData(textureAtlasName: string, textureName: string): TextureData | null
  • Parameters

    • textureAtlasName: string
    • textureName: string

    Returns TextureData | null

Private isSupportMesh

  • _isSupportMesh(): boolean
  • Returns boolean

sortSlots

  • _sortSlots(): void

addDragonBonesData

  • addDragonBonesData(data: DragonBonesData, name?: string | null): void
    • 将 DragonBonesData 实例缓存到工厂中。
    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • data: DragonBonesData

      DragonBonesData 实例。

    • Optional name: string | null

      为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)

    Returns void

addTextureAtlasData

  • addTextureAtlasData(data: TextureAtlasData, name?: string | null): void
    • 将 TextureAtlasData 实例缓存到工厂中。
    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • data: TextureAtlasData

      TextureAtlasData 实例。

    • Optional name: string | null

      为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)

    Returns void

buildArmature

  • buildArmature(armatureName: string, dragonBonesName?: undefined | string, skinName?: undefined | string, textureAtlasName?: undefined | string): Armature | null
    • 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。
    example
        let armature = factory.buildArmature("armatureName", "dragonBonesName");
        armature.clock = factory.clock;
    
    see

    dragonBones.Armature

    see

    dragonBones.Armature

    see

    dragonBones.Armature

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • armatureName: string

      骨架数据名称。

    • Optional dragonBonesName: undefined | string

      DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架)

    • Optional skinName: undefined | string

      皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据(如果未设置,则使用默认的皮肤数据)。

    • Optional textureAtlasName: undefined | string

    Returns Armature | null

    骨架。

buildArmatureDisplay

  • buildArmatureDisplay(armatureName: string, dragonBonesName?: undefined | string, skinName?: undefined | string, textureAtlasName?: undefined | string): null | DisplayData
  • Parameters

    • armatureName: string
    • Optional dragonBonesName: undefined | string
    • Optional skinName: undefined | string
    • Optional textureAtlasName: undefined | string

    Returns null | DisplayData

changeSkin

  • changeSkin(armature: Armature, skin: SkinData, exclude?: Array<string> | null): boolean
    • 已废弃,请参考 {@link #replaceSkin}。
    deprecated
    language

    zh_CN

    Parameters

    • armature: Armature
    • skin: SkinData
    • Optional exclude: Array<string> | null

    Returns boolean

clear

  • clear(disposeData?: undefined | false | true): void
    • 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。
    version

    DragonBones 4.5

    language

    zh_CN

    Parameters

    • Optional disposeData: undefined | false | true

      是否释放数据。

    Returns void

copyAnimationsToArmature

  • copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: undefined | string, fromDragonBonesDataName?: undefined | string, replaceOriginalAnimation?: undefined | false | true): boolean
    • 已废弃,请参考 {@link #replaceAnimation}。
    deprecated
    language

    zh_CN

    Parameters

    • toArmature: Armature
    • fromArmatreName: string
    • Optional fromSkinName: undefined | string
    • Optional fromDragonBonesDataName: undefined | string
    • Optional replaceOriginalAnimation: undefined | false | true

    Returns boolean

createArmatureNode

Private getAllDragonBonesData

  • getAllDragonBonesData(): Map<DragonBonesData>

Private getAllTextureAtlasData

  • getAllTextureAtlasData(): Map<Array<TextureAtlasData>>
  • Returns Map<Array<TextureAtlasData>>

getArmatureData

  • getArmatureData(name: string, dragonBonesName?: undefined | string): ArmatureData | null
    • 获取特定的骨架数据。
    see

    dragonBones.ArmatureData

    version

    DragonBones 5.1

    language

    zh_CN

    Parameters

    • name: string

      骨架数据名称。

    • Optional dragonBonesName: undefined | string

      DragonBonesData 实例的缓存名称。

    Returns ArmatureData | null

getDragonBonesData

  • getDragonBonesData(name: string): DragonBonesData | null
    • 获取特定的 DragonBonesData 实例。
    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • name: string

      DragonBonesData 实例的缓存名称。

    Returns DragonBonesData | null

    DragonBonesData 实例

getDragonBonesDataByRawData

  • getDragonBonesDataByRawData(rawData: any): null | DragonBonesData

getDragonBonesDataByUUID

  • getDragonBonesDataByUUID(uuid: any): null | DragonBonesData

getTextureAtlasData

  • getTextureAtlasData(name: string): Array<TextureAtlasData> | null
    • 获取特定的 TextureAtlasData 实例列表。
    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • name: string

      TextureAtlasData 实例缓存名称。

    Returns Array<TextureAtlasData> | null

initUpdate

  • initUpdate(dt?: undefined | number): void

parseDragonBonesData

  • parseDragonBonesData(rawData: any, name?: string | null, scale?: undefined | number): DragonBonesData | null
    • 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。
    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    version

    DragonBones 4.5

    language

    zh_CN

    Parameters

    • rawData: any

      原始数据。

    • Optional name: string | null

      为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)

    • Optional scale: undefined | number

      为所有的骨架指定一个缩放值。 (默认: 1.0)

    Returns DragonBonesData | null

    DragonBonesData 实例

parseTextureAtlasData

  • parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: undefined | number): TextureAtlasData
    • 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。
    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    version

    DragonBones 4.5

    language

    zh_CN

    Parameters

    • rawData: any

      原始贴图集数据。

    • textureAtlas: any

      贴图集对象。

    • Optional name: string | null

      为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称)

    • Optional scale: undefined | number

      为贴图集指定一个缩放值。 (默认: 1.0)

    Returns TextureAtlasData

    TextureAtlasData 实例

removeDragonBonesData

  • removeDragonBonesData(name: string, disposeData?: undefined | false | true): void
    • 移除 DragonBonesData 实例。
    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    see

    dragonBones.DragonBonesData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • name: string

      DragonBonesData 实例缓存名称。

    • Optional disposeData: undefined | false | true

      是否释放数据。 (默认: true)

    Returns void

removeDragonBonesDataByUUID

  • removeDragonBonesDataByUUID(uuid: string, disposeData?: undefined | false | true): void

removeTextureAtlasData

  • removeTextureAtlasData(name: string, disposeData?: undefined | false | true): void
    • 移除 TextureAtlasData 实例。
    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    see

    dragonBones.TextureAtlasData

    version

    DragonBones 3.0

    language

    zh_CN

    Parameters

    • name: string

      TextureAtlasData 实例的缓存名称。

    • Optional disposeData: undefined | false | true

      是否释放数据。

    Returns void

replaceAnimation

  • replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: undefined | false | true): boolean
    • 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。
    example
        let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
        let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
        if (armatureDataB) {
        factory.replaceAnimation(armatureA, armatureDataB);
        }
    
    see

    dragonBones.ArmatureData

    see

    dragonBones.ArmatureData

    version

    DragonBones 5.6

    language

    zh_CN

    Parameters

    • armature: Armature

      骨架。

    • armatureData: ArmatureData

      骨架数据。

    • Optional isOverride: undefined | false | true

      是否完全覆盖原来的动画。(默认: false)。

    Returns boolean

Private replaceDisplay

  • replaceDisplay(slot: Slot, displayData: DisplayData, displayIndex?: undefined | number): void
  • Parameters

    • slot: Slot
    • displayData: DisplayData
    • Optional displayIndex: undefined | number

    Returns void

replaceSkin

  • replaceSkin(armature: Armature, skin: SkinData, isOverride?: undefined | false | true, exclude?: Array<string> | null): 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"]);
        }
    
    see

    dragonBones.SkinData

    see

    dragonBones.SkinData

    version

    DragonBones 5.6

    language

    zh_CN

    Parameters

    • armature: Armature

      骨架。

    • skin: SkinData

      皮肤数据。

    • Optional isOverride: undefined | false | true

      是否完全覆盖原来的皮肤。 (默认: false)

    • Optional exclude: Array<string> | null

      不需要被替换的插槽名称列表。

    Returns boolean

replaceSlotDisplay

  • replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: undefined | number): boolean
    • 用特定的显示对象数据替换特定插槽当前的显示对象数据。 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。
    example
        let slot = armature.getSlot("weapon");
        factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
    
    version

    DragonBones 4.5

    language

    zh_CN

    Parameters

    • dragonBonesName: string

      DragonBonesData 实例的缓存名称。

    • armatureName: string

      骨架数据名称。

    • slotName: string

      插槽数据名称。

    • displayName: string

      显示对象数据名称。

    • slot: Slot

      插槽。

    • Optional displayIndex: undefined | number

      被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据)

    Returns boolean

Private replaceSlotDisplayList

  • replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean
  • Parameters

    • dragonBonesName: string | null
    • armatureName: string
    • slotName: string
    • slot: Slot

    Returns boolean

update

  • update(dt: number): void

Private updateTextureAtlasData

  • updateTextureAtlasData(name: string, textureAtlases: Array<any>): void
  • Parameters

    • name: string
    • textureAtlases: Array<any>

    Returns void

Static getInstance

Generated using TypeDoc