From b80ccec46be24704b8327acb2deb45180c53f867 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Fri, 25 Dec 2015 19:34:33 +0800 Subject: [PATCH] Do cleanups in onPreDestroy for action, event listeners and schedules --- cocos2d/core/CCNode.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 973de7e60e..c3d89c4d43 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -307,21 +307,21 @@ var Node = cc.Class({ // destroy immediate so its _onPreDestroy can be called component._destroyImmediate(); } + + // Actions + this.stopAllActions(); + + // Schedules + this.unscheduleAllCallbacks(); // Remove all listeners + cc.eventManager.removeListeners(this); for (i = 0, len = this.__eventTargets.length; i < len; ++i) { var target = this.__eventTargets[i]; target && target.targetOff(this); } this.__eventTargets.length = 0; - if (this._touchListener) { - cc.eventManager.removeListener(this._touchListener); - } - if (this._mouseListener) { - cc.eventManager.removeListener(this._mouseListener); - } - // remove from persist if (this._persistNode) { cc.game.removePersistRootNode(this);