// If you don't do cleanup, the child's actions will not get removed and the // its scheduledSelectors_ dict will not get released! if (doCleanup) { child->cleanup(); } #if CC_ENABLE_GC_FOR_NATIVE_OBJECTS auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); if (sEngine) { sEngine->releaseScriptObject(this, child); } #endif// CC_ENABLE_GC_FOR_NATIVE_OBJECTS // set parent nil at the end child->setParent(nullptr);
_children.erase(childIndex); }
Node* Node::getChildByName(conststd::string& name) const { CCASSERT(!name.empty(), "Invalid name"); std::hash<std::string> h; size_t hash = h(name); for (constauto& child : _children) { // Different strings may have the same hash code, but can use it to compare first for speed if(child->_hashOfName == hash && child->_name.compare(name) == 0) return child; } returnnullptr; }