diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 0bb6984f74..fdaf2db470 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -489,6 +489,24 @@ var Node = cc.Class({ } }, + /** + * !#en + * Destroy all children from the node, and release all their own references to other objects.
+ * Actual destruct operation will delayed until before rendering. + * !#zh + * 销毁所有子节点,并释放所有它们对其它对象的引用。
+ * 实际销毁操作会延迟到当前帧渲染前执行。 + * @method destroyAllChildren + * @example + * node.destroyAllChildren(); + */ + destroyAllChildren: function () { + var children = this._children; + for (var i = 0; i < children.length; ++i) { + children[i].destroy(); + } + }, + _onPreDestroy: function () { var i, len;