cocos2d-lua中的removeFromParent()的cleanup的true与false的区别是什么?
jerkzhang
cocos2d-x的C++版本中是有removeFromParentAndCleanup的:
virtual void removeFromParent () Removes this node itself from its parent node with a cleanup. More... virtual void removeFromParentAndCleanup (bool cleanup) Removes this node itself from its parent node. More...
Lua版本则更加精简,合并成removeFromParent (cleanup) 一个方法。
默认的cleanup是true,所以大多情况使用的案例中都是参数缺省状态。
true的意思,就是从父节点中移除此节点,且停止该节点的所有动画。
false的意思,则是从父节点移除此节点,但该节点的动画则是继续的,只是不在父节点中了而已。
这其中的区别可以通过removeFromParent再重新加入addTo指定图层节点中来展示:
如果是true的话,还原到图层节点中,则是静止的;
而如果当初cleanup参数用的是false的话,再还原到图层节点中,则是继续先前的动画状态。