Cocos2d-x 3.0 node and node hierarchy

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.