MCPcopy Create free account
hub / github.com/esengine/esengine / removeChildAt

Method removeChildAt

packages/fairygui/src/core/GComponent.ts:125–153  ·  view source on GitHub ↗

* Remove child at index * 移除指定位置的子对象

(index: number, bDispose: boolean = false)

Source from the content-addressed store, hash-verified

123 * 移除指定位置的子对象
124 */
125 public removeChildAt(index: number, bDispose: boolean = false): GObject {
126 if (index < 0 || index >= this._children.length) {
127 throw new Error('Invalid child index: ' + index);
128 }
129
130 const child = this._children[index];
131 child._parent = null;
132
133 if (child.sortingOrder !== 0) {
134 this._sortingChildCount--;
135 }
136
137 this._children.splice(index, 1);
138
139 if (child.internalVisible) {
140 const childDisplay = child.displayObject;
141 if (this._displayObject && childDisplay) {
142 this._displayObject.removeChild(childDisplay);
143 }
144 }
145
146 this.setBoundsChangedFlag();
147
148 if (bDispose) {
149 child.dispose();
150 }
151
152 return child;
153 }
154
155 /**
156 * Remove children in range

Callers 2

removeChildMethod · 0.95
removeChildrenMethod · 0.95

Calls 3

setBoundsChangedFlagMethod · 0.95
disposeMethod · 0.65
removeChildMethod · 0.45

Tested by

no test coverage detected