Node Tree · Cocos Creator (2024)

We've learnt that by combining Node and Components we can create all kinds of image, text and interactive elements in the scene. We can use Node Tree panel to arrange their render order and hierarchy to make things organized.

Introduce to Node Tree Panel

When creating and positioning nodes in Scene panel you get the convenience of WYSIWYG style editing. While Node Tree provides an organized tree view where you can easily select and arrange nodes no matter if they are big, small or invisible. Please read Node Tree to learn the basic instruction of the interface.

Node Tree (Scene Graph)

Node tree is a data structure that arranges the hierarchy of nodes in scene, it's also called Scene Graph in cocos2d-x term.

You can read the Basic concepts chapter of the Cocos2d-x programmer guide, it describes the node tree very well with some pictures below.

Here's a simple game scene with background image, 3 actors, some text and a start game button:

Node Tree · Cocos Creator (1)

Every visual element is a node, when it comes down to game development we usually don't put all nodes flat in scene, but arrange them according to their category and render order.

Node Tree · Cocos Creator (2)

Each two nodes connected with an arrow have parent-child relationship. We call the one above 'parent' and the one below 'child'. This graph looks like this in Node Tree panel:

Node Tree · Cocos Creator (3)

We use parent nodes to hold similar nodes together. In real projects we have many more options that can fit specific needs. Let's go over the details of parent-child relationship and how can we utilize them in real project.

Local Coordinate System for Node

In previous section Local Coordinate System we understand that one of the key feature of parent child relationship is to transform child node within Local Coordinate System.

The World Coordinate System's origin is at the bottom left of screen. If there's no parent child relationship and all nodes are using World Coordinates, when we want two nodes to be at the center of the background node we will have coordinates like this:

Node Tree · Cocos Creator (4)

Since there's no relationship between the center nodes and the background node, their position values are all under world coordinate system and hard to relate to each other. If we want to move the actors within the background range we need to calculate the limit manually.

Now let's get help from local coordinate system, drag our two actor nodes under the Parent node, now their Position property will be like:

Node Tree · Cocos Creator (5)

Since the anchor point of Parent node is at (0.5, 0.5) (its center), the local coordinate system use the center as origin. The two actor nodes' position become (-100, 0) and (100, 0). It's very easy to get the relative position between these two nodes and the background node. Make it more friendly to designer. It's also easier to get the background edge position, for example the right most x position of the parent node would be (parentNode.width/2, 0).

If we want multiple nodes to move/scale/rotate as a whole, the parent child relationship allow us to only care about parent node's transform. The image below shows applying scale and rotation transform on parent node, and the children will follow.

Node Tree · Cocos Creator (6)

In real game project we will have a lot of actors made of combined nodes. Let's see how can we manage our node tree based on logic.

Manage nodes by logical category

Below it's a typical hero actor that made of multiple nodes:

Node Tree · Cocos Creator (7)

We have Sprite and Animation component on body node, to control the main visual appearance of the actor. A shadow sprite need to be rendered under other actors so we seprate that as shadow node. At last the in game hit point UI has its own node group, the parent node is called HPBar.

This is a typical case of organizing node tree based on logic. We can control body to play animation and flip as we want; we can update HPBar based on current hit point; their mutual parent player used to control character's movement, and can be inserted as a group into other layer or scene.

Managing Render Order

In the above example let's pay attention to body and shadow node's order in Node Tree panel, and their actual render order in Scene panel. The engine will render all nodes according to the order in Node Tree, from top to bottom. So that the node on bottom will be drawn over the node on top.

In a parent child relationship, the parent node is always on top, so child node will be rendered last. That's why we make a separate body node in the example, so that we can specify the exact order of shadow and body.

Node Count Optimization

Please note, although it's convenient to use parent node as container to group up other nodes, but the total node count in a scene will have impact on the node tree initialization time. We should avoid adding unnecessary nodes just for the cause of 'keep things organized'. Try to combine functions of multiple nodes as much as you can.

Node Tree · Cocos Creator (2024)

FAQs

How do you destroy nodes in Cocos Creator? ›

Destroying node

Nodes can be destroyed by the function node. destroy() . It's worth mentioning that node removing will not happen immediately, but will be executed after the logic update for the present frame is complete. After a node is destroyed, it is in the invalid state.

What are node properties in Cocos Creator? ›

Nodes have the following properties:
  • A node contains a set of base attributes (Position, Rotation, Scale), and nodes are organized together by a set of relative transformation relationships, as described in coordinate systems and node transformation properties.
  • The update order between nodes is cascading.
Jun 3, 2024

Is Cocos Creator good? ›

Cocos Creator is more than a efficient, lightweight, open-source, cross-platform graphics engine: it's also a platform to create 3D content in real time. It is not only flawless for 2D and 3D game development, it also provides integral solutions for automotive, XR, Metaverse and Education.

How much does Cocos Creator cost? ›

Cocos Creator is free to use and has no royalty fees.

What is the difference between Cocos2d and cocos creator? ›

Getting to know Cocos2d-x and Cocos Creator

It provides powerful tools to handle graphics, animations, and game logic. On the other hand, Cocos Creator is an integrated development environment based on Cocos2d-x with a more user-friendly and visual approach to game creation.

How do you use the spine in Cocos creator? ›

You can create a spine node in three ways:
  1. Drag the Spine assets directly from Assets to Node Tree:
  2. Drag the Spine assets directly from Assets to Scene:
  3. Drag the Spine assets directly from Assets to the Skeleton Data property of the Spine Skeleton component in the Properties panel.
Jul 19, 2024

How do you destroy a Kubernetes node? ›

To remove a Kubernetes Node:

Wait until the workloads are gracefully deleted and the Kubernetes Node is removed. Open your Git project repository with Reclass model on the cluster level. In infra/config. yml , remove the definition of the Kubernetes Node in question under the reclass:storage:node pillar.

How do you disable nodes in substance designer? ›

long-awaited#SubstanceDesigner long awaited feature is finally there: you can jow disable node(s) using shift+D 😎 #texturing #3dart #MadeWithSubstance #gameart #vfx.

How do I delete nodes in Midas? ›

Delete nodes. From the Main Menu select Model > Nodes > Delete. Select Geometry > Nodes > Delete in the Menu tab of the Tree Menu. Delete Nodes in the Icon Menu.

Top Articles
First-Year Student (Freshman) Admission Requirements < MSU
What the Big 12 can learn from the Sun Belt as conference realignment looms | Hunsucker
Where To Go After Howling Pit Code Vein
Lengua With A Tilde Crossword
Farepay Login
Arkansas Gazette Sudoku
Black Gelato Strain Allbud
Boggle Brain Busters Bonus Answers
Gunshots, panic and then fury - BBC correspondent's account of Trump shooting
Umn Pay Calendar
Autozone Locations Near Me
Select Truck Greensboro
“In my day, you were butch or you were femme”
Moparts Com Forum
Five Day National Weather Forecast
Playgirl Magazine Cover Template Free
Tcgplayer Store
Conan Exiles Colored Crystal
Walgreens San Pedro And Hildebrand
Wausau Marketplace
Self-Service ATMs: Accessibility, Limits, & Features
Governor Brown Signs Legislation Supporting California Legislative Women's Caucus Priorities
kvoa.com | News 4 Tucson
Myql Loan Login
How To Find Free Stuff On Craigslist San Diego | Tips, Popular Items, Safety Precautions | RoamBliss
Bento - A link in bio, but rich and beautiful.
Mineral Wells Skyward
Drying Cloths At A Hammam Crossword Clue
Pioneer Library Overdrive
Watson 853 White Oval
Pacman Video Guatemala
Ugly Daughter From Grown Ups
Salons Open Near Me Today
Workboy Kennel
Ark Unlock All Skins Command
Glossytightsglamour
Lichen - 1.17.0 - Gemsbok! Antler Windchimes! Shoji Screens!
Greater Keene Men's Softball
Instafeet Login
19 Best Seafood Restaurants in San Antonio - The Texas Tasty
15 Best Things to Do in Roseville (CA) - The Crazy Tourist
Trap Candy Strain Leafly
303-615-0055
Obituaries in Hagerstown, MD | The Herald-Mail
Lucifer Morningstar Wiki
Senior Houses For Sale Near Me
Mikayla Campinos Alive Or Dead
Okta Hendrick Login
Mkvcinemas Movies Free Download
The Significance Of The Haitian Revolution Was That It Weegy
How Did Natalie Earnheart Lose Weight
Les BABAS EXOTIQUES façon Amaury Guichon
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 5907

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.