| 478 | } |
| 479 | |
| 480 | void Node::addChild(Node* child, int order, String tag) { |
| 481 | AssertIf(child == nullptr, "add invalid child (nullptr) to node."); |
| 482 | AssertIf(child->_parent, "child already added. It can't be added again."); |
| 483 | AssertIf(child->_flags.isOn(Node::Cleanup), "add invalid child (disposed) to node."); |
| 484 | |
| 485 | if (child->_flags.isOn(Node::UnManaged)) { |
| 486 | child->_flags.setOff(Node::UnManaged); |
| 487 | } |
| 488 | |
| 489 | if (child->_flags.isOn(Node::InWaitingList)) { |
| 490 | child->_flags.setOff(Node::InWaitingList); |
| 491 | SharedDirector.removeFromWaitingList(child); |
| 492 | } |
| 493 | |
| 494 | child->setTag(tag); |
| 495 | child->setOrder(order); |
| 496 | if (!_children) { |
| 497 | _children = Array::create(); |
| 498 | } |
| 499 | Node* last = nullptr; |
| 500 | if (!_children->isEmpty()) { |
| 501 | last = _children->getLast()->to<Node>(); |
| 502 | } |
| 503 | _children->add(Value::alloc(child)); |
| 504 | if (last && last->getOrder() > child->getOrder()) { |
| 505 | _flags.setOn(Node::Reorder); |
| 506 | } |
| 507 | child->_parent = this; |
| 508 | child->updateRealColor3(); |
| 509 | child->updateRealOpacity(); |
| 510 | if (_flags.isOn(Node::Running)) { |
| 511 | child->onEnter(); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | void Node::addChild(Node* child, int order) { |
| 516 | AssertIf(child == nullptr, "add invalid child(nullptr) to node."); |
no test coverage detected