cocos2dx-lua

cocos2dx-lua is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 38 tokens per session (3,191 once invoked), scanned A, original, MIT.

Coding guidance for Cocos2d-x Lua, a Lua-based game development framework. It covers scene objects, touch input, animations, scheduled callbacks, and cleanup of memory and event handlers.

In plain words
What is it for?
Writing or reviewing Cocos2d-x Lua scenes, layers, interfaces, touch handling, actions, schedulers, and object cleanup.
Why use it?
It helps prevent problems such as lingering timers, touch events reaching the wrong layer, failed animations, crashes after scene changes, and memory that keeps growing.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Writing or reviewing Cocos2d-x Lua scenes, layers, interfaces, touch handling, actions, schedulers, and object cleanup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill cocos2dx-lua
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cocos2dx-lua

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cocos2dx-lua

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos2dx-lua.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,191 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.03191
Opus 5.5 $0.00015 $0.01276
Sonnet 5.5 $0.00008 $0.00638
Haiku 4.5 $0.00004 $0.00319

Measured 3mo ago against content hash 9134c3b9247c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cocos2dx-lua scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/cocos2dx-lua/SKILL.md · 197 lines

How it starts

The opening of the file, as written. The whole thing — 197 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cocos2d-x Lua 最佳实践

何时用

  • 编写任何 Cocos2d-x Lua 场景、Layer、UI 组件脚本前。
  • 发现内存持续增长、退出场景后内存未释放时。
  • 触摸事件穿透、多层点击响应混乱,或事件监听器未被清理时。
  • 动作(Action)执行异常、Scene 切换后动画仍在报错时。
  • 调度器回调在节点销毁后仍被调用,导致访问空节点崩溃时。

核心规则

1. 节点生命周期:addChild/removeChild 必须配对,退出前清理一切

规则: 每个 addChild 都要有对应的清理路径(removeChild 或场景切换自动销毁);onEnter/onExit 是注册/注销外部资源(调度器、事件)的标准时机,不要在构造函数或任意时机注册后忘记注销。

为什么: Cocos2d-x 的 C++ 底层使用引用计数(retain/release),Lua 侧持有的 userdata 会阻止对象释放。AI 生成代码时最常犯的错误:在一个 Layer 里 addChild 了子节点,场景切换时只 removeFromParent 了 Layer,但子节点上挂的调度器回调和事件监听器没有清理,C++ 对象引用计数不归零,内存持续增长。新手则常在 init 里注册调度器,在 onExit 里忘记反注册,下次进场景又注册一次,定时器越堆越多。

怎么做:

  • 在 onEnter 里注册调度器和事件监听器,在 onExit 里注销。
  • 场景/Layer 退出时调用 node:unscheduleAllCallbacks() 和 eventDispatcher:removeEventListenersForTarget(node)。
  • 临时创建的节点用完即 removeFromParent(true)(true = cleanup,会停止其上的 Action 和调度器)。
  • 养成习惯:每加一个子节点,立刻想好"它什么时候被移除"。

2. 触摸事件:EventListener 正确注册与移除,处理吞噬与层级冲突

规则: 触摸事件必须用 cc.EventListenerTouchOneByOne 或 cc.EventListenerTouchAllAtOnce 注册到 eventDispatcher,不用旧的 setTouchEnabled;setSwallowTouches(true) 只在确实需要阻止穿透时设置,并理解其对下层 Listener 的影响;节点移除前必须 removeEventListenersForTarget。

为什么: Cocos2d-x Lua 里触摸 bug 几乎全部源于两个问题:(1)新手混用新旧 API——layer:setTouchEnabled(true) 在 3.x 里已废弃,和 EventDispatcher 的优先级体系完全独立,导致点击没响应却不报错,排查极为困难;(2)AI 生成的 Listener 注册了但没有对应的注销,节点 removeChild 后 C++ 对象已析构,触摸事件仍然回调进来,访问已释放的 Lua userdata 直接崩溃。setSwallowTouches 设错方向时,弹窗后面的按钮照样可以被点击,产生逻辑混乱。

怎么做:

  • 统一用 cc.EventListenerTouchOneByOne:create() + eventDispatcher:addEventListenerWithSceneGraphPriority(listener, node)。
  • 弹窗、遮罩层上设 listener:setSwallowTouches(true) 拦截穿透;普通 UI 组件默认不吞噬,让事件往下传。
  • onExit 里:cc.Director:getInstance():getEventDispatcher():removeEventListenersForTarget(self)。
  • 多层 UI 共存时,用 addEventListenerWithFixedPriority 显式指定优先级,避免隐式顺序导致的不确定性。

3. 调度器:用引擎 scheduler,销毁前一定 unschedule

规则: 所有定时逻辑通过 node:scheduleOnce、node:schedule、或 cc.Director:getInstance():getScheduler():scheduleScriptFunc 驱动;不自建基于 update 计数器的"假计时器";节点销毁前调用 node:unscheduleAllCallbacks()。

Read the full file on GitHub · 197 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 197 lines · 38 tokens per session scan A 9134c3b9247c

Subscribe to this mod's changes

cocos2dx-lua is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 5mo ago), licensed MIT. It adds 38 tokens to every session and 3,191 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

cocos2dx-lua compared with skills from other repositories

cocos2dx-lua next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cocos2dx-luaWade-DevCode/awesome-coding-skills-cnSkill75mo agoMITA38Claude Code, Codex
bevy-ecs-rustfindscripter/everything-skillsSkill12todaynoneA114Claude Code
executing-plansjnMetaCode/superpowers-zhSkill8.6k15d agoMITA46Claude Code
chinese-git-workflowjnMetaCode/superpowers-zhSkill8.6k15d agoMITA69Claude Code
chinese-code-reviewjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code
chinese-commit-conventionsjnMetaCode/superpowers-zhSkill8.6k15d agoMITA65Claude Code
chinese-documentationjnMetaCode/superpowers-zhSkill8.6k15d agoMITA62Claude Code