Adding ScriptingEngine callback for onCleanup event

This commit is contained in:
Rohan Kuruvilla 2012-10-22 10:48:22 -07:00 committed by James Chen
parent 0d43d53eb7
commit 16d5659b17
2 changed files with 11 additions and 3 deletions

View File

@ -456,8 +456,13 @@ void CCNode::cleanup()
{ {
// actions // actions
this->stopAllActions(); this->stopAllActions();
this->unscheduleAllSelectors(); this->unscheduleAllSelectors();
if ( m_eScriptType != kScriptTypeNone)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnCleanup);
}
// timers // timers
arrayMakeObjectsPerformSelector(m_pChildren, cleanup, CCNode*); arrayMakeObjectsPerformSelector(m_pChildren, cleanup, CCNode*);
} }
@ -838,6 +843,8 @@ void CCNode::onExit()
} }
arrayMakeObjectsPerformSelector(m_pChildren, onExit, CCNode*); arrayMakeObjectsPerformSelector(m_pChildren, onExit, CCNode*);
} }
void CCNode::registerScriptHandler(int nHandler) void CCNode::registerScriptHandler(int nHandler)

View File

@ -62,7 +62,8 @@ enum {
kCCNodeOnEnter, kCCNodeOnEnter,
kCCNodeOnExit, kCCNodeOnExit,
kCCNodeOnEnterTransitionDidFinish, kCCNodeOnEnterTransitionDidFinish,
kCCNodeOnExitTransitionDidStart kCCNodeOnExitTransitionDidStart,
kCCNodeOnCleanup
}; };
/** @brief CCNode is the main element. Anything that gets drawn or contains things that get drawn is a CCNode. /** @brief CCNode is the main element. Anything that gets drawn or contains things that get drawn is a CCNode.