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

/cocosair-ui-2d

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Build Canvas UI with sprites, Label text, layout and widgets. Use for missing UI, viewport alignment, 2D draw order, BMFont binding or AIR_E_LABEL_WRAP.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencescommon-mistakes.md

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

Derived from the cocosair-ui-2d 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] Waiting on a Creator font-asset pipeline for Label

Wrong:

const font = await loadFont('./assets/my.font');   // no such font-asset import in AIR
label.font = font;

Correct:

label.string = 'Hello';                             // system font: leave label.font unset
const handle = await loadBitmapFont('/assets/font.fnt', { bank });   // authored face = BMFont only
label.font = handle.font;

AIR has no font-asset pipeline (docs/manual/creating-text.md:38); Label draws with the platform system font when font is null, and the only supported authored-font route is BMFont via parseFnt, createBitmapFont and loadBitmapFont (docs/manual/bitmap-font-loading.md:3-26).

[HIGH] Leaving the UI layer unset or the camera unbound

Wrong:

const node = new Node('Panel');                     // default layer is not a UI layer
node.addComponent(Sprite);
const canvas = canvasNode.addComponent(Canvas);      // no camera ever linked

Correct:

node.layer = Layers.Enum.UI_2D;                     // same bit as camera.visibility
uiCamera.visibility = Layers.Enum.UI_2D;
canvas.cameraComponent = uiCamera;                  // nothing draws until the Canvas owns a camera

createUICanvas sets node.layer, camera.visibility and canvas.cameraComponent consistently (src/air/ui-kit.ts:38, :61, :65); a hand-built Canvas must do all three, because the Canvas getter returns null until the setter links a camera (src/cocos/2d/framework/canvas.ts:92-102).

[MEDIUM] Reading the manual as "RichText and LabelAtlas are unavailable"

Wrong:

import { RichText, LabelAtlas } from 'cocosair';     // RichText is not a bare export name

Correct:

import { RichTextComponent, LabelAtlas } from 'cocosair';   // RichText ships only as the alias

docs/manual/creating-text.md:38 frames LabelAtlas/RichText as Creator editor workflow, which is stale for the runtime surface: LabelAtlas is exported bare and RichText is exported only as RichText as RichTextComponent (build/cocosair.module.js export block, currently :161574). What is absent is the font-asset authoring pipeline, not the components (src/cocos/2d/components/rich-text.ts:157).

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
[
  "put sprites, labels or controls on screen",
  "UI renders nothing despite visible nodes",
  "widgets must realign after a viewport change",
  "bind an existing bitmap font to Label",
  "2D sprites and labels overlap in the wrong order"
]
owns
[
  "ui-canvas",
  "sprite-label",
  "widget-layout",
  "ui-controls",
  "font-binding",
  "sorting-2d"
]
not_for
[
  "load or parse a bitmap font -> cocosair-assets",
  "sprite masks and DOM overlays -> cocosair-graphics-and-dom",
  "native input and action mapping -> cocosair-input-action"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用 Canvas、布局、控件、Label、位图字体和二维排序。用于 UI 构建、文本显示或交互布局问题。"
}

README badge

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