[LayaAir 2.0]Node.prototype.removeChildren移除计数有问题

直接看源码,此问题不管高低版本都存在:
removeChildren(beginIndex = 0, endIndex = 0x7fffffff) {
if (this._children && this._children.length > 0) {
var childs = this._children;
if (beginIndex === 0 && endIndex >= childs.length - 1) {
var arr = childs;
this._children = Node.ARRAY_EMPTY;
}
else {
arr = childs.splice(beginIndex, endIndex - beginIndex);
}
for (var i = 0, n = arr.length; i < n; i++) {
arr[i]._setParent(null);
}
}
return this;
}
splice第二个参数表删除长度,那么两个下标之间的数量不应该是endIndex-beginIndex+1吗?这是很基本的计数问题啊。。
假设有个节点p,想要移除内部除最后一个之外的子节点,那么那么按理是调用p.removeChildren(0,p.numChildren-2);结果界面会剩两个子节点;
那么改成p.removeChildren(0,p.numChildren-1);结果子节点全部移除了。。
微信图片_20201103150730.png
已邀请:

kylin9718

赞同来自:

感谢反馈
我们引擎已经在github开源,欢迎直接提交修改
https://github.com/layabox/layaair

要回复问题请先

商务合作
商务合作