Derived from src/cocos/dragon-bones/DragonBonesAtlasAsset.ts, src/cocos/dragon-bones/DragonBonesAsset.ts, src/cocos/dragon-bones/ArmatureDisplay.ts, src/cocos/dragon-bones/CCFactory.ts, src/cocos/dragon-bones/CCTextureData.ts, src/cocos/dragon-bones/CCSlot.ts, src/cocos/dragon-bones/index.ts, src/node_modules/@cocos/dragonbones-js/out/dragonBones.js, docs/notes/dragonbones-notes.md, examples/dragonbones-basic/main.js, build/cocosair.module.js (as of 2026-10-10).
What it does
DragonBones is the fully runnable skeletal 2D subsystem of the default bundle. An ArmatureDisplay
component plays an armature built from two JSON strings (skeleton plus atlas) and one Texture2D,
skinning on the vendored upstream @cocos/dragonbones-js algorithm. Unlike Spine it needs no wasm
backend: it is pure TypeScript against a real parser, so an armature that is wired correctly draws
on the first frame. The bundle export block of build/cocosair.module.js (currently :161574)
carries index$1 as dragonBones, and the component classes resolve through that namespace.
Construction chain (three objects and one key)
new DragonBonesAtlasAsset()takes no name argument (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:44). ItsatlasJsonsetter runsJSON.parse(:53-59, parse at:59), so hand it the raw atlas text, not aJsonAsset.texturewants aTexture2D(:86-90).new DragonBonesAsset(name)(src/cocos/dragon-bones/DragonBonesAsset.ts:67-70) takes its skeleton through thedragonBonesJsontext setter (:58).CCFactory.getInstance()(src/cocos/dragon-bones/CCFactory.ts:65) is the shared parser and builder used by both assets (:129,:136).asset.init(factory, atlasUuid)returns the armature keyuuid#atlasUUID(src/cocos/dragon-bones/DragonBonesAsset.ts:99-128). When the asset is built manually, the uuid falls back to the parsed data name (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:126).
Contracts
- The
ArmatureDisplaysetters are the refresh mechanism, so order matters.dragonAsset(src/cocos/dragon-bones/ArmatureDisplay.ts:203-216) anddragonAtlasAsset(:226-231) each rebuild; assign both assets before settingarmatureName(:239-245), which also rebuilds. - Cache mode defaults to
REALTIME(src/cocos/dragon-bones/ArmatureDisplay.ts:513) and_defaultCacheModesilently downgrades to it whenever caching is unavailable (:352-363); a cached-mode request is not a guarantee you get cached skinning. armatureis a METHOD, not a field (src/cocos/dragon-bones/ArmatureDisplay.ts:1469); reading it as a property gives a function, not the live armature.playAnimation(name, playTimes)treats0as play-once semantics, so looping requires-1(src/cocos/dragon-bones/ArmatureDisplay.ts:1269,docs/notes/dragonbones-notes.md:68).premultipliedAlphadefaults tofalse(src/cocos/dragon-bones/ArmatureDisplay.ts:412), the opposite ofsp.Skeleton, so a shared material copied between the two subsystems is wrong on one side.- Events go through
addEventListeneron the display (src/cocos/dragon-bones/ArmatureDisplay.ts:1428) with DragonBones event names, not the Cocos node emitter.
The vendored dragonbones-js boundary
src/cocos/dragon-bones/index.ts:105 re-exports all of @cocos/dragonbones-js, shipped as
src/node_modules/@cocos/dragonbones-js/out/dragonBones.js (15174 lines) and regenerated by
npm run vendor:npm. Because that file is the upstream algorithm, AnimationCacheMode, Slot,
Armature and the texture-data classes are named exactly as upstream - do not rename them to a
Cocos-style spelling. The AIR-side bridges are CCTextureAtlasData and CCTextureData, which
carry a SpriteFrame per region (src/cocos/dragon-bones/CCTextureData.ts:37, :105), and
CCSlot, which bakes its vertices from those regions (src/cocos/dragon-bones/CCSlot.ts:38,
:229-238).
Gotchas
- The atlas asset will not accept a texture until an
ImageAssetis wrapped into aTexture2D;examples/dragonbones-basic/main.js:239-252shows the required wrap beforeatlasAsset.textureis set. atlasJsonanddragonBonesJsonare text setters that parse (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:53-59,src/cocos/dragon-bones/DragonBonesAsset.ts:58); passing a loadedJsonAssetobject assigns the wrong shape and the armature stays static.- Setting
armatureNamebefore both assets are attached rebuilds against an incomplete factory and yields no armature; the armature keyuuid#atlasUUID(src/cocos/dragon-bones/DragonBonesAsset.ts:99-128) only exists once the atlas asset has been parsed. - A
playAnimation(name, 0)call that finishes and holds is not a bug in the loop flag; pass-1(src/cocos/dragon-bones/ArmatureDisplay.ts:1269).