Bug #3290
By dumganhar Posted 2013-12-30 05:38
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:
<pre>
A
|----B
|----C
</pre>
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:
<pre>
arrayMakeObjectsPerformSelector(m_pChildren, onEnter, CCNode*);
this->resumeSchedulerAndActions();
m_bRunning = true;
if (m_eScriptType != kScriptTypeNone)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnter);
}
</pre>
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.
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:
<pre>
A
|----B
|----C
</pre>
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:
<pre>
arrayMakeObjectsPerformSelector(m_pChildren, onEnter, CCNode*);
this->resumeSchedulerAndActions();
m_bRunning = true;
if (m_eScriptType != kScriptTypeNone)
{
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnter);
}
</pre>
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.