SuperAPI AI Directory

cocos-scene

General & other

View repository

Updated 10-16 01:19

About this skill

Cocos Creator 3.8 Scene Creation

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

  1. Right-click in the Hierarchy Manager and select "Create"
  2. Or use the "Node" menu in the menu bar
  3. Supports creating empty nodes or nodes with components

Node Operations

  1. Select Node: click in the Hierarchy Manager or Scene Editor
  2. Move Node: modify position in the Property Inspector
  3. Hierarchy Adjustment: drag a node under a parent node to change its hierarchy

Adding Components

  1. Select the node
  2. Click "Add Component" in the Property Inspector
  3. 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