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.

referencestiledmap.md

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

Derived from src/cocos/tiledmap/tiled-map.ts, src/cocos/tiledmap/tiled-layer.ts, src/cocos/tiledmap/tiled-object-group.ts, src/cocos/tiledmap/tiled-types.ts, src/cocos/tiledmap/tiled-tile.ts, src/cocos/tiledmap/assembler/simple.ts, src/cocos/2d/framework/ui-renderer.ts, examples/tiledmap-basic/main.js, docs/notes/tiled-map-notes.md, docs/manual/tiled-culling-and-dirty-state.md, docs/manual/tiled-object-queries.md, build/cocosair.module.js (as of 2026-10-10).

What it does

TiledMap renders a TMX map built entirely at run time from strings and sprite frames - there is no Creator importer and no uuid graph. The bundle export block of build/cocosair.module.js (currently :161574) carries TiledMap, TiledMapAsset, TiledLayer, TiledObjectGroup, TiledTile and TiledUserNodeData. Layers and object groups are ordinary UIRenderer batched nodes, so they inherit the UI camera and the markForUpdateRenderData dirty machinery.

Construction chain (a bag of parallel arrays)

_applyFile zips spriteFrameNames, spriteFrameSizes and spriteFrames into lookup maps, zips tsxFileNames with tsxFiles[i].text, then hands tmxXmlStr to TMXMapInfo (src/cocos/tiledmap/tiled-map.ts:340-388, tsx map :375-380, parse call :382). A tileset whose sourceImage has no matching frame logs warnID(16406, i) (:478) and drops those tiles. tmxAsset assignment is what builds the layer nodes (src/cocos/tiledmap/tiled-map.ts:104-110), and __preload applies lazily only if an asset was set before enable (:327), so assign the asset first. TiledMap.enableCulling fans the value out to every layer (:125-131) and layer-level enableCulling marks render data directly (src/cocos/tiledmap/tiled-layer.ts:229-236).

The refresh ladder (culling dirty is not render-data dirty)

  • setTileGIDAt(gid, x, y, flags) masks the flipped bits off the incoming gid (src/cocos/tiledmap/tiled-layer.ts:693-694), throws on an out-of-range cell (:699), and flags is the fourth argument (:711).
  • Single-cell and rectangle writes share _updateTileForGID, which updates tile data, marks culling state dirty and schedules the renderer. The UI renderer queue deduplicates the layer within a frame.
  • The assembler calls updateCulling() first, then rebuilds based on dirty state, animation, TiledNodes and transform changes. Culling recalculates the visible rectangle only when enabled.
  • Both setters update an active static layer on the next render even with culling off or a stationary camera. TSX animation still uses its independent native ticking path.

Object queries and coordinate rewriting

  • getObjectsByType('solid') matches the TMX class (legacy type) string, while a number matches the TMXObjectType enum (src/cocos/tiledmap/tiled-object-group.ts:179, className declared at src/cocos/tiledmap/tiled-types.ts:454).
  • getRawObjects() returns frozen snapshots of the original TMX numbers (src/cocos/tiledmap/tiled-object-group.ts:174, built at :259-260) because _init rewrites object.x and object.y in place and keeps the originals only in object.offset (:263-284, ortho flip :284, isometric divisor tileSize.height :276-283).
  • Only TEXT and IMAGE objects get child nodes (src/cocos/tiledmap/tiled-object-group.ts:286-300); RECT, ELLIPSE, POLYGON and POLYLINE stay pure data.
  • TiledTile exposes the cell through a grid accessor, not gid (src/cocos/tiledmap/tiled-tile.ts:109-118).

Gotchas

  • setCullingDirty(true) only sets a flag. Use the tile setters to edit cells and schedule a refresh; no manual reactivation is needed.
  • Passing flags in the third position mis-throws or drops flip bits; the signature order is (gid, x, y, flags) (src/cocos/tiledmap/tiled-layer.ts:711).
  • Trusting object.x after _init gives the rewritten engine coordinate, not the authored TMX value; read getRawObjects() for the original (src/cocos/tiledmap/tiled-object-group.ts:174).

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