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

Function hitTest

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

* Hit test * 碰撞检测

(globalX: number, globalY: number)

Source from the content-addressed store, hash-verified

562 * 碰撞检测
563 */
564 public hitTest(globalX: number, globalY: number): DisplayObject | null {
565 if (!this._visible || !this._touchable) {
566 return null;
567 }
568
569 const localPoint = this.globalToLocal(new Point(globalX, globalY));
570
571 if (
572 localPoint.x >= 0 &&
573 localPoint.x < this._width &&
574 localPoint.y >= 0 &&
575 localPoint.y < this._height
576 ) {
577 for (let i = this._children.length - 1; i >= 0; i--) {
578 const hit = this._children[i].hitTest(globalX, globalY);
579 if (hit) return hit;
580 }
581 return this;
582 }
583
584 return null;
585 }
586
587 // Dirty flags | 脏标记
588

Callers

nothing calls this directly

Calls 2

globalToLocalMethod · 0.80
hitTestMethod · 0.45

Tested by

no test coverage detected