Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-2d-subsystems

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Build DragonBones, TiledMap, 2D/3D particles and billboards from runtime data. Use for raw asset strings, missing pixels, MotionStreak or Spine backend limits.

  • 12 files
  • 56.9 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-2d-subsystems

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesdragonbones.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

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)

  1. new DragonBonesAtlasAsset() takes no name argument (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:44). Its atlasJson setter runs JSON.parse (:53-59, parse at :59), so hand it the raw atlas text, not a JsonAsset. texture wants a Texture2D (:86-90).
  2. new DragonBonesAsset(name) (src/cocos/dragon-bones/DragonBonesAsset.ts:67-70) takes its skeleton through the dragonBonesJson text setter (:58).
  3. CCFactory.getInstance() (src/cocos/dragon-bones/CCFactory.ts:65) is the shared parser and builder used by both assets (:129, :136).
  4. asset.init(factory, atlasUuid) returns the armature key uuid#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 ArmatureDisplay setters are the refresh mechanism, so order matters. dragonAsset (src/cocos/dragon-bones/ArmatureDisplay.ts:203-216) and dragonAtlasAsset (:226-231) each rebuild; assign both assets before setting armatureName (:239-245), which also rebuilds.
  • Cache mode defaults to REALTIME (src/cocos/dragon-bones/ArmatureDisplay.ts:513) and _defaultCacheMode silently downgrades to it whenever caching is unavailable (:352-363); a cached-mode request is not a guarantee you get cached skinning.
  • armature is 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) treats 0 as play-once semantics, so looping requires -1 (src/cocos/dragon-bones/ArmatureDisplay.ts:1269, docs/notes/dragonbones-notes.md:68).
  • premultipliedAlpha defaults to false (src/cocos/dragon-bones/ArmatureDisplay.ts:412), the opposite of sp.Skeleton, so a shared material copied between the two subsystems is wrong on one side.
  • Events go through addEventListener on 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 ImageAsset is wrapped into a Texture2D; examples/dragonbones-basic/main.js:239-252 shows the required wrap before atlasAsset.texture is set.
  • atlasJson and dragonBonesJson are text setters that parse (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:53-59, src/cocos/dragon-bones/DragonBonesAsset.ts:58); passing a loaded JsonAsset object assigns the wrong shape and the armature stays static.
  • Setting armatureName before both assets are attached rebuilds against an incomplete factory and yields no armature; the armature key uuid#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).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "build DragonBones assets from raw JSON strings",
  "TiledMap edits do not redraw or resolve objects",
  "particles compute but render no pixels; createAirParticleSystem 3D emitters/trails CPU/GPU",
  "Spine skeleton stays blank without an error",
  "billboard or motion trail is invisible"
]
owns
[
  "dragonbones",
  "tiledmap",
  "particle-2d",
  "billboard",
  "motion-streak",
  "spine-limits"
]
not_for
[
  "basic UI layout and controls -> cocosair-ui-2d",
  "3D skeleton deformation -> cocosair-skinning-morph",
  "remote asset caching -> cocosair-assets"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置 Spine、DragonBones、TiledMap、二维粒子和 Billboard 的原生运行时契约。用于资源构造、空白画面或子系统能力边界问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-2d-subsystems