🐛 fix UI repositioning and mouse coords after window resize

This commit is contained in:
2026-03-20 12:19:57 +00:00
parent 5828f40497
commit 8ed67313a8
4 changed files with 41 additions and 12 deletions

View File

@@ -92,9 +92,9 @@ export class BuildingSystem {
if (!this.active) return
// Update ghost to follow mouse (snapped to tile grid)
const ptr = this.scene.input.activePointer
const worldX = this.scene.cameras.main.scrollX + ptr.x
const worldY = this.scene.cameras.main.scrollY + ptr.y
const ptr = this.scene.input.activePointer
const worldX = ptr.worldX
const worldY = ptr.worldY
const tileX = Math.floor(worldX / TILE_SIZE)
const tileY = Math.floor(worldY / TILE_SIZE)
const snapX = tileX * TILE_SIZE + TILE_SIZE / 2
@@ -142,8 +142,8 @@ export class BuildingSystem {
}
private tryPlace(ptr: Phaser.Input.Pointer): void {
const worldX = this.scene.cameras.main.scrollX + ptr.x
const worldY = this.scene.cameras.main.scrollY + ptr.y
const worldX = ptr.worldX
const worldY = ptr.worldY
const tileX = Math.floor(worldX / TILE_SIZE)
const tileY = Math.floor(worldY / TILE_SIZE)

View File

@@ -80,9 +80,8 @@ export class FarmingSystem {
// ─── Tool actions ─────────────────────────────────────────────────────────
private useToolAt(ptr: Phaser.Input.Pointer): void {
const cam = this.scene.cameras.main
const worldX = cam.scrollX + ptr.x
const worldY = cam.scrollY + ptr.y
const worldX = ptr.worldX
const worldY = ptr.worldY
const tileX = Math.floor(worldX / TILE_SIZE)
const tileY = Math.floor(worldY / TILE_SIZE)
const state = stateManager.getState()