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

Method cleanup

core/2d/Node.cpp:217–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217void 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
242std::string Node::getDescription() const
243{

Callers 7

resetChildMethod · 0.45
~LayerMultiplexMethod · 0.45
replaceSceneMethod · 0.45
popToSceneStackLevelMethod · 0.45
resetMethod · 0.45
setNextSceneMethod · 0.45
setNotificationNodeMethod · 0.45

Calls 2

stopAllActionsMethod · 0.95

Tested by

no test coverage detected