| 215 | } |
| 216 | |
| 217 | void Node::cleanup() |
| 218 | { |
| 219 | #if AX_ENABLE_SCRIPT_BINDING |
| 220 | ScriptEngineManager::sendNodeEventToLua(this, kNodeOnCleanup); |
| 221 | #endif // #if AX_ENABLE_SCRIPT_BINDING |
| 222 | |
| 223 | // actions |
| 224 | this->stopAllActions(); |
| 225 | // timers |
| 226 | this->unscheduleAllCallbacks(); |
| 227 | |
| 228 | // NOTE: Although it was correct that removing event listeners associated with current node in Node::cleanup. |
| 229 | // But it broke the compatibility to the versions before v3.16 . |
| 230 | // User code may call `node->removeFromParent(true)` which will trigger node's cleanup method, when the node |
| 231 | // is added to scene again, event listeners like EventListenerTouchOneByOne will be lost. |
| 232 | // In fact, user's code should use `node->removeFromParent(false)` in order not to do a cleanup and just remove node |
| 233 | // from its parent. For more discussion about why we revert this change is at |
| 234 | // https://github.com/cocos2d/cocos2d-x/issues/18104. We need to consider more before we want to correct the old and |
| 235 | // wrong logic code. For now, compatiblity is the most important for our users. |
| 236 | // _eventDispatcher->removeEventListenersForTarget(this); |
| 237 | |
| 238 | for (const auto& child : _children) |
| 239 | child->cleanup(); |
| 240 | } |
| 241 | |
| 242 | std::string Node::getDescription() const |
| 243 | { |
no test coverage detected