Reference http://cn.cocos2d-x.org/doc/cocos2d-x-3.0/d3/d82/classcocos2d_1_1_node.html
The member functions associated with child and parent are as follows:
Children and Parent |
virtual void |
AddChild (Node *child) |
|
Add a child node to the container, Z-order is 0. More...
|
|
virtual void |
AddChild (Node *child, int localzorder) |
|
Add a child node to the container, and the parameter has a local z-axis order. More...
|
|
virtual void |
AddChild (Node *child, int localzorder, int tag) |
|
Adds a child node to the container, with a z-axis order and a marker. More...
|
|
Virtual Node * |
Getchildbytag (int tag) |
|
Gets a child node from the container through its markup. More...
|
|
Virtual vector< Node * > & |
GetChildren () |
|
Returns an array of child nodes. More...
|
|
Virtual Const vector< Node * > & |
GetChildren () const |
|
Virtual ssize_t |
Getchildrencount () const |
|
Returns the total number of child nodes more ...
|
|
virtual void |
SetParent (Node *parent) |
|
Set parent nodes sets the parent node more ...
|
|
Virtual Node * |
GetParent () |
|
Returns a pointer to the parent node. More...
|
|
Virtual Const NODE * |
GetParent () const |
|
virtual void |
Removefromparent () |
|
Removes a node from the parent node, with a cleanup parameter. If this node is a lone node, nothing will happen. More...
|
|
virtual void |
Removefromparentandcleanup (bool cleanup) |
|
Remove a node from the parent node if the node is a lone node, nothing happens. More...
|
|
virtual void |
RemoveChild (Node *child, bool cleanup=true) |
|
Removing a child from the container, depending on the cleanup parameter, clears all active actions. More...
|
|
virtual void |
Removechildbytag (int tag, bool cleanup=true) |
|
Removes a child from a container by marking the value. Depending on the cleanup parameter, all active actions are cleared at the same time. More...
|
|
virtual void |
Removeallchildren () |
|
Remove all children from the container with a cleanup. More...
|
|
virtual void |
Removeallchildrenwithcleanup (bool cleanup) |
|
Removing all children from the container, depending on the cleanup parameter, also clears all active actions. More...
|
|
virtual void |
Reorderchild (Node *child, int localzorder) |
|
Reorder a child and set a new z-axis value. More...
|
|
virtual void |
Sortallchildren () |
|
Before painting, arrange all the child arrays once, rather than sorting each time you add or delete child nodes. This method can improve performance in a large number of ways. More... |
I am also learning how to use the concrete. But what's more useful is that through this, you can call the node, a node tree in the game any point of nodes can be obtained through this method, easy game development.
As an example,
For example, a parkour game scene has three layers (animation, background, score) where the animation layer state changes, logically requiring another score layer to make a corresponding change, through the child and the parent method can quickly locate the score layer.
"The Learning experience of node class GetParent and Getchildbytag () in COCOS2DX"