From 0d7f1e367271afa86ac8461189227fb8c86f83a4 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 28 Jul 2015 16:05:47 +0800 Subject: [PATCH] Reorder the logic of script invocation for onEnter, onExit etc to the beginning of the function --- cocos/2d/CCNode.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 6f77d4387a..67b38bad92 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1410,14 +1410,6 @@ Mat4 Node::transform(const Mat4& parentTransform) void Node::onEnter() { - if (_onEnterCallback) - _onEnterCallback(); - - if (_componentContainer && !_componentContainer->isEmpty()) - { - _componentContainer->onEnter(); - } - #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { @@ -1426,6 +1418,14 @@ void Node::onEnter() } #endif + if (_onEnterCallback) + _onEnterCallback(); + + if (_componentContainer && !_componentContainer->isEmpty()) + { + _componentContainer->onEnter(); + } + _isTransitionFinished = false; for( const auto &child: _children) @@ -1445,9 +1445,6 @@ void Node::onEnter() void Node::onEnterTransitionDidFinish() { - if (_onEnterTransitionDidFinishCallback) - _onEnterTransitionDidFinishCallback(); - #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { @@ -1455,6 +1452,9 @@ void Node::onEnterTransitionDidFinish() return; } #endif + + if (_onEnterTransitionDidFinishCallback) + _onEnterTransitionDidFinishCallback(); _isTransitionFinished = true; for( const auto &child: _children) @@ -1470,9 +1470,6 @@ void Node::onEnterTransitionDidFinish() void Node::onExitTransitionDidStart() { - if (_onExitTransitionDidStartCallback) - _onExitTransitionDidStartCallback(); - #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { @@ -1481,6 +1478,9 @@ void Node::onExitTransitionDidStart() } #endif + if (_onExitTransitionDidStartCallback) + _onExitTransitionDidStartCallback(); + for( const auto &child: _children) child->onExitTransitionDidStart(); @@ -1494,14 +1494,6 @@ void Node::onExitTransitionDidStart() void Node::onExit() { - if (_onExitCallback) - _onExitCallback(); - - if (_componentContainer && !_componentContainer->isEmpty()) - { - _componentContainer->onExit(); - } - #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { @@ -1510,6 +1502,14 @@ void Node::onExit() } #endif + if (_onExitCallback) + _onExitCallback(); + + if (_componentContainer && !_componentContainer->isEmpty()) + { + _componentContainer->onExit(); + } + this->pause(); _running = false;