mirror of https://github.com/axmolengine/axmol.git
Merge pull request #2650 from varlucian/onentertransitionfinnished
OnEnterTransitionDidFinish was called twice when a node is added in onEnter
This commit is contained in:
commit
c862357b50
|
@ -86,6 +86,7 @@ CCNode::CCNode(void)
|
|||
, m_bVisible(true)
|
||||
, m_bIgnoreAnchorPointForPosition(false)
|
||||
, m_bReorderChildDirty(false)
|
||||
, m_bIsTransitionFinished(false)
|
||||
, m_nScriptHandler(0)
|
||||
, m_nUpdateScriptHandler(0)
|
||||
{
|
||||
|
@ -597,7 +598,10 @@ void CCNode::addChild(CCNode *child, int zOrder, int tag)
|
|||
if( m_bRunning )
|
||||
{
|
||||
child->onEnter();
|
||||
child->onEnterTransitionDidFinish();
|
||||
// prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter
|
||||
if (m_bIsTransitionFinished) {
|
||||
child->onEnterTransitionDidFinish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,6 +899,8 @@ void CCNode::transform()
|
|||
|
||||
void CCNode::onEnter()
|
||||
{
|
||||
m_bIsTransitionFinished = false;
|
||||
|
||||
arrayMakeObjectsPerformSelector(m_pChildren, onEnter, CCNode*);
|
||||
|
||||
this->resumeSchedulerAndActions();
|
||||
|
@ -909,6 +915,8 @@ void CCNode::onEnter()
|
|||
|
||||
void CCNode::onEnterTransitionDidFinish()
|
||||
{
|
||||
m_bIsTransitionFinished = true;
|
||||
|
||||
arrayMakeObjectsPerformSelector(m_pChildren, onEnterTransitionDidFinish, CCNode*);
|
||||
|
||||
if (m_eScriptType == kScriptTypeJavascript)
|
||||
|
|
|
@ -1372,6 +1372,7 @@ protected:
|
|||
///< Used by CCLayer and CCScene.
|
||||
|
||||
bool m_bReorderChildDirty; ///< children order dirty flag
|
||||
bool m_bIsTransitionFinished; ///< flag to indicate whether the transition was finished
|
||||
|
||||
int m_nScriptHandler; ///< script handler for onEnter() & onExit(), used in Javascript binding and Lua binding.
|
||||
int m_nUpdateScriptHandler; ///< script handler for update() callback per frame, which is invoked from lua & javascript.
|
||||
|
|
Loading…
Reference in New Issue