MCPcopy Create free account
hub / github.com/axmolengine/axmol / addChildHelper

Method addChildHelper

core/2d/Node.cpp:993–1053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

991}
992
993void Node::addChildHelper(Node* child, int localZOrder, int tag, std::string_view name, bool setTag)
994{
995 auto assertNotSelfChild([this, child]() -> bool {
996 for (Node* parent(getParent()); parent != nullptr; parent = parent->getParent())
997 if (parent == child)
998 return false;
999
1000 return true;
1001 });
1002 (void)assertNotSelfChild;
1003
1004 AXASSERT(assertNotSelfChild(), "A node cannot be the child of his own children");
1005
1006 if (_children.empty())
1007 {
1008 this->childrenAlloc();
1009 }
1010
1011 this->insertChild(child, localZOrder);
1012
1013 child->setParent(this);
1014
1015 if (_childFollowCameraMask)
1016 {
1017 child->setCameraMask(this->getCameraMask());
1018 child->applyMaskOnEnter(true);
1019 }
1020
1021 if (setTag)
1022 {
1023 child->setTag(tag);
1024 child->updateParentChildrenIndexer(child->getName());
1025 }
1026 else
1027 {
1028 child->setName(name);
1029 child->updateParentChildrenIndexer(child->getTag());
1030 }
1031
1032 child->updateOrderOfArrival();
1033
1034 if (_running)
1035 {
1036 child->onEnter();
1037 // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter
1038 if (_isTransitionFinished)
1039 {
1040 child->onEnterTransitionDidFinish();
1041 }
1042 }
1043
1044 if (_cascadeColorEnabled)
1045 {
1046 updateCascadeColor();
1047 }
1048
1049 if (_cascadeOpacityEnabled)
1050 {

Callers

nothing calls this directly

Calls 15

childrenAllocMethod · 0.95
insertChildMethod · 0.95
applyMaskOnEnterMethod · 0.80
setTagMethod · 0.80
getTagMethod · 0.80
updateOrderOfArrivalMethod · 0.80
getParentMethod · 0.45
emptyMethod · 0.45
setParentMethod · 0.45
setCameraMaskMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected