Node Description: A node is a basic element of a scenario diagram. The basic element of a scene map must be a Node object or a subclass of a Node object.
Here, we can see layers, menuitem, scene, Sprite, tmxtiledmap (parsing and rendering tmx maps), and particle system (particle system base class ).
Node is the root class of these classes
Basic node operations
- Create a node
Node * childnode = node: Create ();
- Add a new subnode
Node-> addchild (childnode, Z depth, tag );
- Search for subnodes
Node * node = node-> getchildbytag (TAG)
- Node-> removechildtag (TAG, true) deletes a subnode and stops all actions on the node.
- Node-> removechild (childnode) deletes a node through the node pointer
- Node-> removeallchildrenwithcleanup (true) delete all subnodes and stop all actions on these subnodes
- Node-> removefromparentandcleanup (true): deletes a node from the parent node and stops all actions on the node.
Important node attributes
- anchorpoint
the anchorpoint specifies the texture and the node origin (that is, the point where the position is set).
the default value of the anchorpoint is (0.5, 0.5 ), not a pixel, but a multiplier. (0.5, 0.5) indicates that the anchor is located at the point where the texture length is multiplied by 0.5 and the width is multiplied by 0.5, that is, the center of the texture.
although the image position of the node may have changed, changing the value of the anchor does not actually change the position of the node, in fact, only the relative position of the texture relative to the position you set is equivalent to the texture in the moving node, rather than the node itself.
position = (0.5), anchorpoin = (0.5,)
position = (), anchorpoin =)
position = (5, 5), anchorpoin = (0.66, 0.5)