From d9225b9ad0870292ccefc14c29708c8ffc65608b Mon Sep 17 00:00:00 2001 From: Lucas Habersaat Date: Mon, 22 Jun 2026 20:55:30 +0200 Subject: [PATCH] fix(button): pointer collider box after resize (#50) --- src/frontend/src/ScreenElements/Button.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/frontend/src/ScreenElements/Button.ts b/src/frontend/src/ScreenElements/Button.ts index 495e519..7ad1a5a 100644 --- a/src/frontend/src/ScreenElements/Button.ts +++ b/src/frontend/src/ScreenElements/Button.ts @@ -39,6 +39,16 @@ export class Button extends ex.ScreenElement { onInitialize(_engine: ex.Engine): void { const { height, width } = this; + // Annoying Excalibur bug. It queries the graphics hash grid with worldPos, but ScreenElement transforms + // are in screen space. Setting localBounds activates the path that correctly uses screenPos. + this.pointer.useGraphicsBounds = false; + this.pointer.localBounds = new ex.BoundingBox({ + left: -width / 2, + top: 0, + right: width / 2, + bottom: height, + }); + this._textElement = new Text({ text: this._text, font: paragraphFont,