24 lines
1.0 KiB
JavaScript
24 lines
1.0 KiB
JavaScript
/**
|
|
* Enable / disable hit-testing on an interactive object (Phaser v4).
|
|
*
|
|
* v4 (4.2.1 Giedi) quirk — the trap behind the dead sub-bar buttons:
|
|
* the Phaser 3 idiom `obj.ignorePointer = true` is a NO-OP in the INPUT
|
|
* system (that property belongs to the physics world — matter.js — only).
|
|
* v4's InputManager gates hit-testing on `obj.input.enabled` (see
|
|
* InputManager.inputCandidate: `if (!i || !i.enabled || ...) return false`),
|
|
* and a pointer press lands on only the single TOPMOST hit (topOnly) —
|
|
* so an invisible rect that was "supposed to be off" keeps swallowing
|
|
* every click beneath it, forever.
|
|
*
|
|
* Use this wherever the old code wrote `ignorePointer`:
|
|
*
|
|
* setInteractiveEnabled(obj, false) // the object stops catching clicks
|
|
* setInteractiveEnabled(obj, true) // it catches them again
|
|
*
|
|
* No-op if the object never got setInteractive() — safe either way.
|
|
*/
|
|
export function setInteractiveEnabled(obj, enabled) {
|
|
if (obj && obj.input) obj.input.enabled = !!enabled;
|
|
return obj;
|
|
}
|