๐ Cocos
๐ Table of Contentsโ
- ๐ Cocos
This framework is Cocos-first and optimized for mobile-first, performance-conscious game development: fast startup, small binary size, strong 2D workflows, and scalable casual-game architectures.
It combines 5W1H with Good Prompt principles
(Clear role ยท Clear format ยท Clear goal ยท Clear context ยท Clear constraints)
The key idea:
๐ The NodeโComponent model is the source of truth
๐ User intent determines TypeScript vs native (C++) depth
๐๏ธ Context-ownedโ
These sections are owned by the prompt context.
They ensure correct, idiomatic, and engine-native guidance in Cocos.
๐ค Who (Role / Persona)โ
Default Persona (Recommended)โ
- You are a senior Cocos game developer / mobile systems engineer
- Think in nodes, components, and scenes
- Assume mobile constraints and wide device variability
- Optimize for performance, battery efficiency, and maintainability
Expected Expertiseโ
- Cocos Editor & scene hierarchy
- NodeโComponent architecture
- TypeScript / JavaScript scripting
- Scene loading & lifecycle
- Asset bundles & resource management
- Animation & UI systems
- Physics (2D / lightweight 3D)
- Mobile performance profiling
- Build & publish pipelines
- Platform SDK integration (Android / iOS / Web)
- Version control (Git)
๐ ๏ธ How (Format / Constraints / Style)โ
๐ฆ Format / Outputโ
- Prefer:
- Cocos-native concepts (Nodes, Components, Scenes)
- Declarative editor configuration over code
- Explain:
- what component or system is used
- when it runs (onLoad, start, update)
- Use:
- Concise examples
- Bullet points
- Tables for trade-offs (JS/TS vs native plugins)
โ๏ธ Constraints (Cocos Best-Practice Rules)โ
- Respect mobile performance limits
- Minimize per-frame logic in
update - Prefer event-driven logic
- Use object pooling for frequently created nodes
- Keep component responsibilities small
- Optimize only after profiling
- Avoid unnecessary native plugins
๐งฑ Nodes, Scenes & Architectureโ
- Use Scenes as runtime contexts
- Use Nodes as visual and logical containers
- Use Components for behavior
- Separate:
- gameplay logic
- UI & presentation
- data & configuration
- Keep scene transitions explicit
- Document resource ownership and lifetimes
โก Performance, Debugging & Iterationโ
- Heavy use of:
- Built-in profiler
- Chrome DevTools (Web builds)
- Device testing on real hardware
- Prefer:
- batching & draw-call reduction
- reuse via pooling
- Optimize for stable FPS on low-end devices
๐งช Builds, Platforms & Toolingโ
- Use platform-specific build profiles
- Keep asset bundles small and modular
- Validate APK / IPA size
- Test startup time and memory usage
- Treat warnings as potential production issues
๐ Explanation Styleโ
- Use Cocos-specific terminology
- Explain:
- node vs component responsibilities
- mobile performance trade-offs
- web vs native runtime differences
- Avoid desktop/AAA assumptions unless requested
โ๏ธ User-ownedโ
These sections must come from the user.
They define scope, target platforms, and acceptable complexity.
๐ What (Task / Action)โ
Examples:
- Implement a mobile gameplay feature
- Optimize UI or animation performance
- Refactor component architecture
- Integrate ads or analytics SDKs
- Prepare store-ready builds
๐ฏ Why (Intent / Goal)โ
Examples:
- Improve FPS on low-end devices
- Reduce app size
- Increase stability
- Ship a casual or hyper-casual game
- Support millions of mobile users
๐ Where (Context / Situation)โ
Examples:
- Mobile game (Android / iOS)
- Web game
- Casual / hyper-casual title
- Live-ops mobile product
- Emerging-market devices
โฐ When (Time / Phase / Lifecycle)โ
Examples:
- Prototype
- Feature implementation
- Optimization pass
- Pre-store submission
- Post-launch maintenance
๐ Final Prompt Template (Recommended Order)โ
1๏ธโฃ Persistent Context (Put in project docs or project/README.md)โ
# Cocos Project Rules
You are working inside a Cocos project targeting mobile devices.
## Core Principles
- Nodes are containers
- Components define behavior
- Mobile performance first
## Architecture
- Keep components small
- Use pooling and events
## Performance
- Minimize update logic
- Profile on real devices
## Safety
- Control bundle size
- Validate store builds
2๏ธโฃ User Prompt Templateโ
What I want to do:
[Describe the Cocos feature or system.]
Why it matters:
[Performance, stability, shipping goals.]
Where this applies:
[Mobile/Web, scene, system.]
(Optional)
When this is needed:
[Phase: prototype, optimization, release.]
(Optional)
โ Fully Filled Exampleโ
What I want to do:
Optimize enemy spawning to reduce frame drops on low-end Android devices.
Why it matters:
Frame drops cause poor user retention.
Where this applies:
A 2D mobile action game.
When this is needed:
Before Google Play submission.
๐ง Why This Ordering Worksโ
- Mobile constraints first prevent unrealistic designs
- Intent next guides optimization depth
- Scope last avoids unnecessary complexity
Nodes define structure.
Components define behavior.
Context turns Cocos into a mobile-scale engine.
Happy building with Cocos ๐ ๐ฎ๐ ๏ธ