Ensure enemies only lock onto player once they have line of sight

This commit is contained in:
Peter Stockings
2026-01-05 14:46:04 +11:00
parent dba0f054db
commit 45a1ed2253
6 changed files with 199 additions and 33 deletions

View File

@@ -188,4 +188,35 @@ export class FxRenderer {
onComplete: () => text.destroy()
});
}
showAlert(x: number, y: number) {
const screenX = x * TILE_SIZE + TILE_SIZE / 2;
const screenY = y * TILE_SIZE - 8;
const text = this.scene.add.text(screenX, screenY, "!", {
fontSize: "24px",
color: "#ffaa00",
stroke: "#000",
strokeThickness: 3,
fontStyle: "bold"
}).setOrigin(0.5, 1).setDepth(210);
// Exclamation mark stays visible for alert duration
this.scene.tweens.add({
targets: text,
y: screenY - 8,
duration: 200,
yoyo: true,
repeat: 3, // Bounce a few times
ease: "Sine.inOut"
});
this.scene.tweens.add({
targets: text,
alpha: 0,
delay: 900, // Start fading out near end of alert period
duration: 300,
onComplete: () => text.destroy()
});
}
}