Bug #3290

By dumganhar Posted 2013-11-27 08:07

This bug was reported by an email from a game developer.

The email contents are:

Recently, we're developing a JSB game named 《一二三国》, we found a bug in Node.

h3. Reproduce Step:

If there is a node tree like the following:
B and C are the children of A.

If A, B and C have implemented cc.Node.onEnter and they were added to scene graph,
In the implementation of cocos2d-x C++, the order of @onEnter@ is: A->B->C which is also the same as cocos2d-html5.
But in JSB, the order is changed to B->C->A, this will cause compatibility issues between JSB and Html5.

The reason of this issue is:
arrayMakeObjectsPerformSelector(m_pChildren, onEnter, CCNode*);
m_bRunning = true;

if (m_eScriptType != kScriptTypeNone)
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnter);


Since the executed order of @ScripEngineManager::executeXXX@ is after arrayMakeObjectPerformSelector, It will cause the order of @onEnter@ in JSB is B->C->A.

h3. Solution:

We should move @ScripEngineManager::executeXXX@ at the beginning.