fix: HUD elements no longer shift when zooming in/out
setScrollFactor(0) prevents camera scroll but NOT zoom displacement. Added fixToScreen() utility that compensates object positions and scale each frame based on current camera zoom. Applied to all scrollFactor(0) UI elements in GameScene, Minimap, and BossArenaScene. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -59,6 +59,9 @@ import {
|
||||
} from '../run/crisis';
|
||||
import { getEscalationEffects } from '../run/escalation';
|
||||
|
||||
// UI zoom compensation
|
||||
import { fixToScreen } from '../ui/screen-fix';
|
||||
|
||||
// Mycelium imports
|
||||
import { FungalNode } from '../ecs/components';
|
||||
import { spawnFungalNodes } from '../mycelium/nodes';
|
||||
@@ -623,6 +626,16 @@ export class GameScene extends Phaser.Scene {
|
||||
} else {
|
||||
this.phaseText.setColor('#00ff88');
|
||||
}
|
||||
|
||||
// Fix UI element positions for current camera zoom.
|
||||
// setScrollFactor(0) prevents scroll but NOT zoom displacement.
|
||||
const cam = this.cameras.main;
|
||||
fixToScreen(this.statsText, 10, 30, cam);
|
||||
fixToScreen(this.interactionText, cam.width / 2, cam.height - 40, cam);
|
||||
fixToScreen(this.phaseText, cam.width / 2, 12, cam);
|
||||
fixToScreen(this.memoryFlashText, cam.width / 2, cam.height / 2, cam);
|
||||
fixToScreen(this.crisisOverlay, cam.width / 2, cam.height / 2, cam);
|
||||
fixToScreen(this.mycosisOverlay, cam.width / 2, cam.height / 2, cam);
|
||||
}
|
||||
|
||||
/** Find the nearest fungal node within interaction range, or null */
|
||||
|
||||
Reference in New Issue
Block a user