brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
cocos2dExpert game development with Cocos2d-x / Cocos Creator - node tree, components, rendering (OpenGL ES/Metal/Vulkan), physics (Box2D), audio, UI, multi-platform build, and performance.
Independent GitHub snapshot · Automated classification · Original documentation governs
Cocos2d is a family of open-source game frameworks for 2D (and now 3D in Creator) with strong mobile focus. Cocos2d-x is the C++ core; Cocos Creator is the full editor + scene system built on top. This guide focuses on Cocos Creator 3.x (which uses Cocos2d-x under the hood).
Cocos Creator 3.x
Application
Scene -> Node tree
Component (Script, Render, Audio, UI, Physics...)
Scheduler (main loop): tick() -> update() -> lateUpdate()
Director: scene management, frame pacing
director.mainLoop() runs the frame.update(), lateUpdate(), physicsUpdate() with priorities.fixedUpdate() // physics substeps (if using Box2D)
update() // gameplay logic per frame
lateUpdate() // camera, UI follow
render() // GPU submit
Rules:
move() or set RigidBody3D.velocity in fixedUpdate.node.setPosition(lerp(...)) in update().import { Component, _decorator } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('Player')
export class Player extends Component {
@property speed: number = 10;
update(deltaTime: number) {
// movement, animation, input
}
onCollisionEnter(other: Collider) {
// physics callback
}
}
// Emit
this.node.emit('damage', amount);
// Listen
this.node.on('damage', this.onDamage, this);
node.on(): listen on the same node or bubble up.targetOff(): remove all listeners on cleanup.EventTarget).import { instantiate, Prefab, resources } from 'cc';
const bullet = instantiate(this.bulletPrefab);
bullet.setPosition(this.node.worldPosition);
director.getScene().addChild(bullet);
Rule: cache prefab references via @property(Prefab), never load per frame.
| Platform | Renderer |
|---|---|
| Desktop/Mobile (GL) | OpenGL ES 3.1+ |
| iOS / Metal devices | Metal |
| Android Vulkan | Vulkan (via Cocos 3.x) |
| Web | WebGL 2.0 |
Sprite with the same texture/atlas: automatically batched by SpriteBatch/RenderBatch.TexturePacker) aggressively.UIOpacity only on dynamic nodes; static UI should be grouped under a single Opacity parent.@ccclass('CustomEffect')
export class CustomEffect extends RenderableComponent {
getRenderPipeline() { return 'Builtin'; }
// use this.getMaterial(0) to change uniforms
}
RenderPipeline (Forward, Deferred) set in Project Settings.physics-3d / physics-2d.Collider2D/Collider3D + RigidBody2D/RigidBody3D.onBeginContact, onEndContact.physicsGroup in Project Settings.const controller = this.node.getComponent(CharacterController);
controller.move(dir, deltaTime);
RigidBody2D + BoxCollider2D, manual velocity control.CharacterController3D from cc (or use Box2D bullet).AudioSource component: play(), stop(), volume, loop.Sprite, Label, Button, Slider, ScrollView, RichText.Layout component (horizontal/vertical/grid).[0-1, 0-1] (unlike Unity's pivot).Canvas node as root of UI tree; camera renders to UI layer.Widget component for responsive layout (attach to parent edges).| Option | Use |
|---|---|
| TypeScript | Primary, first-class support in Cocos Creator |
| C++ (Cocos2d-x) | Engine extensions, GDExtension-like via bindings |
| Lua | Legacy Cocos2d-x; not primary in Creator 3.x |
@property decorators to expose fields.@property(Node) target: Node;.this.node: current node; this.node.parent: tree up.director.loadScene('sceneName') to switch scenes.skills/game/multiplayer-netcode/SKILL.md..ts scripts, .prefab, .scene, .texture, .anim.resources.load()): load by path within resources/ folder.AssetManager for runtime loading, scene loading.AssetManager.loadBundle from CDN for hot updates.console.time().NodePool or visibility checks).NodePool for bullets/enemies; never instantiate/destroy per event.destroy() is deferred; removeFromParent() + pool recycling is faster.AssetManager bundles explicitly.| System | Budget |
|---|---|
| Gameplay | 8ms |
| Physics | 5ms |
| Render (CPU) | 8ms |
| Audio | 2ms |
| GC / misc | 5ms |
| GPU | 16.6ms (GPU-bound, overlap CPU) |
| Anti-pattern | Consequence | Fix |
|---|---|---|
| Instantiate/destroy per event | Allocation + GC | NodePool |
| All nodes ticking | CPU waste | disable update |
| No texture atlas | Draw calls explode | pack sprites |
| load() per frame | I/O stall | cache preloaded |
| Global variables | GC hits | scoped to class |
this.schedule() in update | multiple timers | use one timer |
skills/game/game-development/cocos2d-patterns/SKILL.md — Cocos2d-x architecture deep diveskills/game/game-engine/patterns/SKILL.md — engine design pattern catalogskills/game/multiplayer-netcode/SKILL.md — networking approach referenceskills/game/game-development/vulkan/SKILL.md — low-level GPU rendering (mobile/desktop)