* Hit test * 碰撞检测
(globalX: number, globalY: number)
| 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 |
nothing calls this directly
no test coverage detected