Analysis of parameters of Addchild and RemoveChild methods in Cocos2d-x

Source: Internet
Author: User
Tags addchild

I. Addchild

virtual void Addchild (node * child, int localzorder, int tag) adds a sub-node to the container, with a z-axis order and a marker.

1. If a child node is added to a "running (active)" node, then ' OnEnter ' and ' onentertransitiondidfinish ' will be called immediately.

2. Parameter resolution

AddChild: Refers to the child member to be added (Node * type, removable sprite, layer, etc.);

Z: Refers to the added ZOrder value, ZOrder refers to the member's level (or depth), the z-value of the member in the small Z-value above the member,

Tag: Refers to the member's tag value, the tag value is a member of the identity, if you lose the variable, you can use Getchildbytag (tag) to find this member.

3. Example

Bulletbox->addchild (bullet, 0, Gamescene::hero_bullet_tag);

Gamescene::hero_bullet_tag is a value in an enum, which is 102

Two. RemoveChild

virtual void removechild (Node * child, bool cleanup) removes a kid from the container, depending on the cleanup parameter, and may erase all active actions.

1. Parameter resolution

Child node to which you want to be deleted.
Cleanup to True indicates that all actions and callbacks on this node will be deleted and false will not be deleted.






Analysis of parameters of Addchild and RemoveChild methods in Cocos2d-x

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.