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.

referencescommon-mistakes.md

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

Derived from the cocosair-2d-subsystems skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Common Mistakes

[HIGH] Treating Spine as runnable out of the box

Wrong: await loadWasmModuleSpine() then sk.skeletonData = data - it resolves without loading anything and the skeleton renders no draw list with no exception, only one console warning.

Correct:

import { sp } from 'cocosair';
const data = new sp.SkeletonData();                // the class is real and importable
console.warn('spine runtime backend not deployed: LV12-10 BLOCKED, no emscripten artifacts');
// deploy spine.wasm / spine.asm.js / spine.js.mem first, then delete the AIR shim override

The shim returns null from every wasmUtil stub (src/cocos/spine/lib/air-spine-instantiate-js.ts:26-52), getRuntimeData() therefore yields null (src/cocos/spine/skeleton-data.ts:199-237) and the skeleton bails at src/cocos/spine/skeleton.ts:791; the unblock path is recorded in docs/notes/spine-asset-sourcing.md:43-47.

[HIGH] Expecting a TiledMap cell edit to redraw itself

Wrong: layer.setTileGIDAt(2, 3, 1) then layer.setCullingDirty(true) - data changes but pixels do not, and the culling flag is never consumed when culling is off.

Correct:

const layer = map.getLayer('ground');
layer.setTileGIDAt(2, 3, 1, TiledMap.TileFlag.DIAGONAL);   // flags is the 4th argument
layer.markForUpdateRenderData();                            // or toggle layer.node.active false then true

_updateTileForGID sets only _cullingDirty (src/cocos/tiledmap/tiled-layer.ts:714-731), which is consumed at the end of updateViewPort (:865) and reached only through the culling path (:913); the measured refresh ladder in examples/tiledmap-basic/main.js:396-405 shows node reactivation as the working rung.

[HIGH] Copying Creator plist blend values into a code-first emitter

Wrong: reusing an exported plist that sets blendFuncSource: 770, blendFuncDestination: 1 - those raw GL constants land out of the gfx BlendFactor range and the emitter simulates but draws nothing.

Correct:

ps.custom = false;                    // true skips _initWithDictionary entirely
ps.file = particleAsset;              // dict came from assetManager.parser.parsePlist
ps.srcBlendFactor = 2;                // gfx BlendFactor.SRC_ALPHA
ps.dstBlendFactor = 1;                // gfx BlendFactor.ONE

_initWithDictionary writes the plist integers straight into BlendFactor slots (src/cocos/particle-2d/particle-system-2d.ts:1062-1063) whose enum ends at 14 (src/cocos/gfx/base/define.ts:505-521), and a missing particleLifespan makes life 0 which zeroes the emission clamp (src/cocos/particle-2d/particle-system-2d.ts:1047, :1055) - both cases simulate perfectly and draw nothing.

[MEDIUM] Importing names the bundle does not export

Wrong: import { MotionStreak2D } and skeleton.registerSpineEventHandler(handler, sp.AnimationEventType.START) - neither name exists here, and the streak wants a Texture2D not a SpriteFrame.

Correct:

import { MotionStreak, sp } from 'cocosair';
const skeleton = node.addComponent(sp.Skeleton);
skeleton.setStartListener((entry) => console.log(entry.animation.name));     // or setEventListener
const streak = node.addComponent(MotionStreak);   // class name is cc.MotionStreak
streak.texture = texture;                          // a Texture2D, not a SpriteFrame

The export block of build/cocosair.module.js (currently :161574) has MotionStreak and MotionStreakAssemblerManager and no MotionStreak2D; registerSpineEventHandler matches nothing in src/, and MotionStreak.texture is typed as a raw texture (src/cocos/particle-2d/motion-streak-2d.ts:143).

[MEDIUM] Reusing Creator asset conventions for atlas and paths

Wrong: atlasAsset.atlasJson = await assetManager.loadRemote(...) and ps.file = await assetManager.loadRemote(...) - the setters want raw text and a parsed plist, and a loadRemote plist arrives as a bare Asset.

Correct:

atlasAsset.atlasJson = text;                     // raw string; the setter parses it
atlasAsset.texture = wrappedTexture2D;           // ImageAsset must be wrapped first
particleAsset._nativeAsset = parsedPlistDict;    // parse the plist yourself, then hand it over
ps.file = particleAsset;
ms.texture = texture;                            // Texture2D, not SpriteFrame

The atlasJson and dragonBonesJson setters parse text (src/cocos/dragon-bones/DragonBonesAtlasAsset.ts:53-59, src/cocos/dragon-bones/DragonBonesAsset.ts:58), a loadRemote plist arrives as a bare Asset (docs/notes/particle-2d-notes.md:45), and examples/dragonbones-basic/main.js:239-252 shows the required ImageAsset to Texture2D wrap before the atlas asset will accept a texture.

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