removeAllChildren: function (cleanup) {
// not using detachChild improves speed here
var children = this._children;
if (cleanup === undefined)
cleanup = true;
for (var i = children.length - 1; i >= 0; i--) {
var node = children[i];
if (node) {
// If you don't do cleanup, the node's actions will not get removed and the
if (cleanup)
node.cleanup();
node.parent = null;
}
}
this._children.length = 0;
},
removeAllChildren 的实现非常简单,你自己包装一个会遍历 destroy 的类似方法就是了