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

Function setChildIndex

packages/fairygui/src/display/DisplayObject.ts:431–440  ·  view source on GitHub ↗

* Set child index * 设置子显示对象的索引

(child: DisplayObject, index: number)

Source from the content-addressed store, hash-verified

429 * 设置子显示对象的索引
430 */
431 public setChildIndex(child: DisplayObject, index: number): void {
432 const currentIndex = this._children.indexOf(child);
433 if (currentIndex < 0) return;
434
435 index = Math.max(0, Math.min(index, this._children.length - 1));
436 if (currentIndex === index) return;
437
438 this._children.splice(currentIndex, 1);
439 this._children.splice(index, 0, child);
440 }
441
442 /**
443 * Swap two children

Callers

nothing calls this directly

Calls 2

maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected