When to use this skill
Use this skill whenever the user wants to:
- Create Cocos2d-x v4 games or applications
- Learn Cocos2d-x v4 core concepts (Node, Sprite, Scene, Action)
- Set up Cocos2d-x v4 development environment
- Work with sprites, textures, animations, and labels
- Implement scene management and node lifecycle
- Handle input events (touch, mouse, keyboard)
- Use physics engine (Box2D) and collision detection
- Implement rendering pipeline, shaders, and particle systems
- Build and deploy games for multiple platforms (Windows, macOS, Linux, Android, iOS)
- Use CMake build system and command-line tools
- Migrate from older Cocos2d-x versions
- Extend engine with custom rendering and script bindings
How to use this skill
To work with Cocos2d-x v4:
Identify the topic from the user's request:
- Engine overview/了解引擎 →
examples/getting-started/about-engine.md
- Quick start/快速上手 →
examples/getting-started/quick-start.md
- Installation/安装配置 →
examples/getting-started/installation.md
- Node and Scene/节点和场景 →
examples/core/node-scene.md
- Sprite/精灵 →
examples/core/sprite.md
- Texture/纹理 →
examples/core/texture.md
- Animation/动画 →
examples/core/animation.md
- Action/动作 →
examples/core/action.md
- Label/标签 →
examples/core/label.md
- Scene management/场景管理 →
examples/core/scene.md
- Input handling/输入处理 →
examples/core/input.md
- Event system/事件系统 →
examples/core/event.md
- Physics/物理引擎 →
examples/advanced/physics.md
- Rendering/渲染 →
examples/advanced/rendering.md
- Shaders/着色器 →
examples/advanced/shader.md
- Particle system/粒子系统 →
examples/advanced/particle.md
- Build system/构建系统 →
examples/tools/build-system.md
- Platform deployment/平台部署 →
examples/tools/deployment.md
Load the appropriate example file from the examples/ directory:
examples/getting-started/about-engine.md - Engine overview and features
examples/getting-started/quick-start.md - Create first project
examples/getting-started/installation.md - Environment setup
examples/core/node-scene.md - Node and Scene concepts
examples/core/sprite.md - Sprite creation and manipulation
examples/core/texture.md - Texture loading and management
examples/core/animation.md - Animation system
examples/core/action.md - Action system and sequences
examples/core/label.md - Label and text rendering
examples/core/scene.md - Scene management and transitions
examples/core/input.md - Touch, mouse, and keyboard input
examples/core/event.md - Event system and listeners
examples/advanced/physics.md - Physics engine integration
examples/advanced/rendering.md - Rendering pipeline
examples/advanced/shader.md - Custom shaders
examples/advanced/particle.md - Particle effects
examples/tools/build-system.md - CMake and build configuration
examples/tools/deployment.md - Platform-specific deployment
Follow the specific instructions in that example file for syntax, structure, and best practices
Each example file contains:
- Instructions: Overview and usage guidelines
- Syntax: API syntax and parameters
- Examples: Complete code examples with explanations
- Reference: Links to official documentation
Generate C++ code following Cocos2d-x v4 conventions:
- Use
USING_NS_CC; for namespace
- Use
CREATE_FUNC() macro for create functions
- Follow Cocos2d-x naming conventions
- Include proper error handling
- Use smart pointers where appropriate
Reference the official documentation:
Use templates when creating new projects:
templates/project-structure.md - Standard project structure
templates/cmake-config.md - CMake configuration examples
Doc mapping (one-to-one with official documentation)
Core Concepts
Node System
- Node: Base class for all display objects
- Scene: Root node of the scene graph
- Sprite: Image display node
- Label: Text display node
- Node hierarchy: Parent-child relationships
Coordinate System
- Origin at bottom-left (OpenGL style)
- Anchor point for positioning
- Local and world coordinates
Action System
- Action: Base class for node transformations
- Sequence: Chain multiple actions
- Spawn: Run actions simultaneously
- Repeat: Repeat actions multiple times
- Ease: Apply easing functions
Scene Management
- Scene transitions
- Scene lifecycle (onEnter, onExit)
- Director for scene management
Input Handling
- Touch events (single and multi-touch)
- Mouse events
- Keyboard events
- Event dispatcher system
Platform Support
Cocos2d-x v4 supports:
- Desktop: Windows, macOS, Linux
- Mobile: Android, iOS
- Web: (via Cocos Creator)
Build System
- CMake: Primary build system
- Command-line tools:
cocos command
- IDE support: Visual Studio, Xcode, Android Studio
Migration Guide
For migrating from older versions:
- Check
examples/migration/ for migration guides
- API changes and compatibility notes
- CMake migration from older build systems
Reference Resources
Keywords
cocos2d-x, cocos2d, game engine, game development, C++ game, 2D game, cross-platform game, sprite, scene, node, action, animation, physics, rendering, shader, particle system, CMake, game framework, 游戏引擎, 游戏开发, 精灵, 场景, 节点, 动作, 动画, 物理引擎, 渲染, 着色器, 粒子系统
Important Notes
- Version: This skill covers Cocos2d-x v4 specifically
- Language: C++ is the primary development language
- Build System: CMake is required for building projects
- Platform: Ensure platform-specific dependencies are installed
- Examples: All code examples use C++ syntax
- Memory Management: Cocos2d-x uses reference counting, be careful with retain/release cycles
- Coordinate System: Uses OpenGL-style coordinates (origin at bottom-left)
- Thread Safety: Most Cocos2d-x operations must be performed on the main thread
能力边界
✅ 适用场景
- 当你需要使用此技能对应的技术栈时
- 当项目需要遵循最佳实践时
- 当需要快速上手或深入理解核心概念时
⚠️ 需要注意
- 复杂业务逻辑需要结合具体场景调整
- 性能优化需要根据实际数据量评估
❌ 不适用场景
常见陷阱 (Gotchas)
- 版本兼容性:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异
- 配置文件格式:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查
- 环境变量:确保所有必要的环境变量已正确设置,敏感信息不要硬编码
- 依赖冲突:多版本共存时注意依赖冲突,使用 lock 文件锁定版本
- 性能陷阱:大数据量场景下注意性能优化,避免 N+1 查询等常见问题
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
1---2name: cocos2d-x3description: Provides comprehensive guidance for Cocos2d-x v4 game engine including scene graph, nodes, sprites, actions, animations, physics, rendering, shaders, and platform deployment. Use when the user asks about Cocos2d-x, needs to create games, implement game features, set up development environments, or deploy games to multiple platforms.4license: Complete terms in LICENSE.txt5---67## When to use this skill89Use this skill whenever the user wants to:10- Create Cocos2d-x v4 games or applications11- Learn Cocos2d-x v4 core concepts (Node, Sprite, Scene, Action)12- Set up Cocos2d-x v4 development environment13- Work with sprites, textures, animations, and labels14- Implement scene management and node lifecycle15- Handle input events (touch, mouse, keyboard)16- Use physics engine (Box2D) and collision detection17- Implement rendering pipeline, shaders, and particle systems18- Build and deploy games for multiple platforms (Windows, macOS, Linux, Android, iOS)19- Use CMake build system and command-line tools20- Migrate from older Cocos2d-x versions21- Extend engine with custom rendering and script bindings2223## How to use this skill2425To work with Cocos2d-x v4:26271. **Identify the topic** from the user's request:28 - Engine overview/了解引擎 → `examples/getting-started/about-engine.md`29 - Quick start/快速上手 → `examples/getting-started/quick-start.md`30 - Installation/安装配置 → `examples/getting-started/installation.md`31 - Node and Scene/节点和场景 → `examples/core/node-scene.md`32 - Sprite/精灵 → `examples/core/sprite.md`33 - Texture/纹理 → `examples/core/texture.md`34 - Animation/动画 → `examples/core/animation.md`35 - Action/动作 → `examples/core/action.md`36 - Label/标签 → `examples/core/label.md`37 - Scene management/场景管理 → `examples/core/scene.md`38 - Input handling/输入处理 → `examples/core/input.md`39 - Event system/事件系统 → `examples/core/event.md`40 - Physics/物理引擎 → `examples/advanced/physics.md`41 - Rendering/渲染 → `examples/advanced/rendering.md`42 - Shaders/着色器 → `examples/advanced/shader.md`43 - Particle system/粒子系统 → `examples/advanced/particle.md`44 - Build system/构建系统 → `examples/tools/build-system.md`45 - Platform deployment/平台部署 → `examples/tools/deployment.md`46472. **Load the appropriate example file** from the `examples/` directory:48 - `examples/getting-started/about-engine.md` - Engine overview and features49 - `examples/getting-started/quick-start.md` - Create first project50 - `examples/getting-started/installation.md` - Environment setup51 - `examples/core/node-scene.md` - Node and Scene concepts52 - `examples/core/sprite.md` - Sprite creation and manipulation53 - `examples/core/texture.md` - Texture loading and management54 - `examples/core/animation.md` - Animation system55 - `examples/core/action.md` - Action system and sequences56 - `examples/core/label.md` - Label and text rendering57 - `examples/core/scene.md` - Scene management and transitions58 - `examples/core/input.md` - Touch, mouse, and keyboard input59 - `examples/core/event.md` - Event system and listeners60 - `examples/advanced/physics.md` - Physics engine integration61 - `examples/advanced/rendering.md` - Rendering pipeline62 - `examples/advanced/shader.md` - Custom shaders63 - `examples/advanced/particle.md` - Particle effects64 - `examples/tools/build-system.md` - CMake and build configuration65 - `examples/tools/deployment.md` - Platform-specific deployment66673. **Follow the specific instructions** in that example file for syntax, structure, and best practices6869 Each example file contains:70 - **Instructions**: Overview and usage guidelines71 - **Syntax**: API syntax and parameters72 - **Examples**: Complete code examples with explanations73 - **Reference**: Links to official documentation74754. **Generate C++ code** following Cocos2d-x v4 conventions:76 - Use `USING_NS_CC;` for namespace77 - Use `CREATE_FUNC()` macro for create functions78 - Follow Cocos2d-x naming conventions79 - Include proper error handling80 - Use smart pointers where appropriate81825. **Reference the official documentation**:83 - Official manual: https://docs.cocos.com/cocos2d-x/v4/manual/zh/84 - API reference: Check `api/` directory for detailed API documentation85 - Examples: Check `examples/` directory for code examples86876. **Use templates** when creating new projects:88 - `templates/project-structure.md` - Standard project structure89 - `templates/cmake-config.md` - CMake configuration examples909192### Doc mapping (one-to-one with official documentation)9394- See examples and API files → https://docs.cocos.com/cocos2d-x/v4/manual/zh/9596## Core Concepts9798### Node System99- **Node**: Base class for all display objects100- **Scene**: Root node of the scene graph101- **Sprite**: Image display node102- **Label**: Text display node103- **Node hierarchy**: Parent-child relationships104105### Coordinate System106- Origin at bottom-left (OpenGL style)107- Anchor point for positioning108- Local and world coordinates109110### Action System111- **Action**: Base class for node transformations112- **Sequence**: Chain multiple actions113- **Spawn**: Run actions simultaneously114- **Repeat**: Repeat actions multiple times115- **Ease**: Apply easing functions116117### Scene Management118- Scene transitions119- Scene lifecycle (onEnter, onExit)120- Director for scene management121122### Input Handling123- Touch events (single and multi-touch)124- Mouse events125- Keyboard events126- Event dispatcher system127128## Platform Support129130Cocos2d-x v4 supports:131- **Desktop**: Windows, macOS, Linux132- **Mobile**: Android, iOS133- **Web**: (via Cocos Creator)134135## Build System136137- **CMake**: Primary build system138- **Command-line tools**: `cocos` command139- **IDE support**: Visual Studio, Xcode, Android Studio140141## Migration Guide142143For migrating from older versions:144- Check `examples/migration/` for migration guides145- API changes and compatibility notes146- CMake migration from older build systems147148## Reference Resources149150- **Official Documentation**: https://docs.cocos.com/cocos2d-x/v4/manual/zh/151- **API Reference**: See `api/` directory152- **Examples**: See `examples/` directory153- **Templates**: See `templates/` directory154155## Keywords156157cocos2d-x, cocos2d, game engine, game development, C++ game, 2D game, cross-platform game, sprite, scene, node, action, animation, physics, rendering, shader, particle system, CMake, game framework, 游戏引擎, 游戏开发, 精灵, 场景, 节点, 动作, 动画, 物理引擎, 渲染, 着色器, 粒子系统158159## Important Notes1601611. **Version**: This skill covers Cocos2d-x v4 specifically1622. **Language**: C++ is the primary development language1633. **Build System**: CMake is required for building projects1644. **Platform**: Ensure platform-specific dependencies are installed1655. **Examples**: All code examples use C++ syntax1666. **Memory Management**: Cocos2d-x uses reference counting, be careful with retain/release cycles1677. **Coordinate System**: Uses OpenGL-style coordinates (origin at bottom-left)1688. **Thread Safety**: Most Cocos2d-x operations must be performed on the main thread169170## 能力边界171172### ✅ 适用场景173- 当你需要使用此技能对应的技术栈时174- 当项目需要遵循最佳实践时175- 当需要快速上手或深入理解核心概念时176177### ⚠️ 需要注意178- 复杂业务逻辑需要结合具体场景调整179- 性能优化需要根据实际数据量评估180181### ❌ 不适用场景182- 不相关的技术栈或框架183- 需要完全自定义的特殊场景184185## 常见陷阱 (Gotchas)1861871. **版本兼容性**:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异1882. **配置文件格式**:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查1893. **环境变量**:确保所有必要的环境变量已正确设置,敏感信息不要硬编码1904. **依赖冲突**:多版本共存时注意依赖冲突,使用 lock 文件锁定版本1915. **性能陷阱**:大数据量场景下注意性能优化,避免 N+1 查询等常见问题192193## 使用流程194195### Step 1: 环境准备196确保开发环境已安装必要的依赖和工具。197198### Step 2: 配置初始化199根据项目需求进行基础配置。200201### Step 3: 核心功能使用202按照示例代码实现核心功能。203204### Step 4: 测试验证205运行测试确保功能正常。206207### Step 5: 部署上线208完成开发后进行部署和监控。