Task Objectives
- This Skill is used for: mastering scene creation, node management, and the component system in Cocos Creator
- Capabilities include: node creation, component addition, scene graph management, node transformation
- Trigger conditions: building game scenes, managing scene hierarchy structures
Overview
A scene is a tree structure composed of nodes, where nodes have a tree-like organizational relationship, and each node can have multiple child nodes. A game is composed of various scenes.
Core Concepts
Node
- Nodes are the basic building blocks of a scene
- Nodes can add components to extend functionality
- Nodes support hierarchical management (parent node/child node)
Node Transformation
- Position: the coordinates of the node in the scene
- Rotation: the rotation angle of the node
- Scale: the scale ratio of the node
- Anchor: the anchor position within the node
Component
- Components are attached to nodes to provide functionality
- Common components: Sprite, Label, Button, Collider, etc.
- Multiple components can be added to the same node
Operation Steps
Creating Nodes
- Right-click in the Hierarchy Manager and select "Create"
- Or use the "Node" menu in the menu bar
- Supports creating empty nodes or nodes with components
Node Operations
- Select Node: click in the Hierarchy Manager or Scene Editor
- Move Node: modify position in the Property Inspector
- Hierarchy Adjustment: drag a node under a parent node to change its hierarchy
Adding Components
- Select the node
- Click "Add Component" in the Property Inspector
- Select the required component type
Prefab
- Save nodes in the scene as prefabs
- Prefabs can be reused
- Modifying a prefab will sync to all instances
Resource Index
Required References
Notes
Performance Optimization
- Avoid overly deep node hierarchies
- Use node pools appropriately
- Disable unnecessary nodes
Best Practices
- Use standardized naming conventions
- Organize the scene structure appropriately
- Set commonly used nodes as prefabs