Quantcast
Channel: Cocos中文社区 - 最新帖子
Viewing all articles
Browse latest Browse all 495283

关于Node的removeAllChildren

$
0
0

    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 的类似方法就是了


Viewing all articles
Browse latest Browse all 495283

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>