From 16d5659b17c9b661d1e8e45cc0320cb7540ee50a Mon Sep 17 00:00:00 2001 From: Rohan Kuruvilla Date: Mon, 22 Oct 2012 10:48:22 -0700 Subject: [PATCH] Adding ScriptingEngine callback for onCleanup event --- cocos2dx/base_nodes/CCNode.cpp | 11 +++++++++-- cocos2dx/base_nodes/CCNode.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 57c36a97f1..b16f1411c8 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -456,8 +456,13 @@ void CCNode::cleanup() { // actions this->stopAllActions(); - this->unscheduleAllSelectors(); - + this->unscheduleAllSelectors(); + + if ( m_eScriptType != kScriptTypeNone) + { + CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnCleanup); + } + // timers arrayMakeObjectsPerformSelector(m_pChildren, cleanup, CCNode*); } @@ -838,6 +843,8 @@ void CCNode::onExit() } arrayMakeObjectsPerformSelector(m_pChildren, onExit, CCNode*); + + } void CCNode::registerScriptHandler(int nHandler) diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index e9595be0de..1fcb35bc27 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -62,7 +62,8 @@ enum { kCCNodeOnEnter, kCCNodeOnExit, kCCNodeOnEnterTransitionDidFinish, - kCCNodeOnExitTransitionDidStart + kCCNodeOnExitTransitionDidStart, + kCCNodeOnCleanup }; /** @brief CCNode is the main element. Anything that gets drawn or contains things that get drawn is a CCNode.