🐛 fix UI repositioning and mouse coords after window resize
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user