feat: add toggleable red glow highlight on followed NPC
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,8 @@ export class GameScene extends Phaser.Scene {
|
||||
private emojiManager!: InteractionEmojiManager;
|
||||
private commandPanel!: CommandPanel;
|
||||
private followCommandPanel!: CommandPanel;
|
||||
private highlightEnabled = false;
|
||||
private highlightedSpriteId: number | null = null;
|
||||
|
||||
constructor() {
|
||||
super({ key: 'GameScene' });
|
||||
@@ -89,6 +91,8 @@ export class GameScene extends Phaser.Scene {
|
||||
} else if (prevMode === 'follow') {
|
||||
this.npcInfoPanel.hide();
|
||||
this.followCommandPanel.hide();
|
||||
this.clearHighlight();
|
||||
this.highlightEnabled = false;
|
||||
}
|
||||
|
||||
// Command panel visibility
|
||||
@@ -101,6 +105,17 @@ export class GameScene extends Phaser.Scene {
|
||||
|
||||
// Spawn NPC command (camera mode only)
|
||||
this.input.keyboard!.addKey('ONE').on('down', () => {
|
||||
if (this.mode === 'follow') {
|
||||
this.highlightEnabled = !this.highlightEnabled;
|
||||
if (this.highlightEnabled) {
|
||||
const npcIds = this.getNpcIds();
|
||||
const targetId = npcIds[this.followTargetIndex];
|
||||
if (targetId != null) this.applyHighlight(targetId);
|
||||
} else {
|
||||
this.clearHighlight();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.mode !== 'camera') return;
|
||||
const cam = this.cameras.main;
|
||||
const centerTileX = Math.floor((cam.scrollX + cam.width / 2) / TILE_SIZE);
|
||||
@@ -265,6 +280,9 @@ export class GameScene extends Phaser.Scene {
|
||||
for (const [id, es] of this.entitySprites) {
|
||||
if (!activeIds.has(id)) {
|
||||
es.sprite.destroy();
|
||||
if (id === this.highlightedSpriteId) {
|
||||
this.highlightedSpriteId = null;
|
||||
}
|
||||
this.entitySprites.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -354,11 +372,17 @@ export class GameScene extends Phaser.Scene {
|
||||
if (left) {
|
||||
this.followTargetIndex = (this.followTargetIndex - 1 + npcIds.length) % npcIds.length;
|
||||
this.followThrottle = 150;
|
||||
if (this.highlightEnabled) {
|
||||
this.applyHighlight(npcIds[this.followTargetIndex]);
|
||||
}
|
||||
this.updateModeText();
|
||||
this.updateFollowPanel();
|
||||
} else if (right) {
|
||||
this.followTargetIndex = (this.followTargetIndex + 1) % npcIds.length;
|
||||
this.followThrottle = 150;
|
||||
if (this.highlightEnabled) {
|
||||
this.applyHighlight(npcIds[this.followTargetIndex]);
|
||||
}
|
||||
this.updateModeText();
|
||||
this.updateFollowPanel();
|
||||
}
|
||||
@@ -414,4 +438,22 @@ export class GameScene extends Phaser.Scene {
|
||||
this.modeText.setText(`Mode: ${this.mode.toUpperCase()} [TAB to toggle]`);
|
||||
}
|
||||
}
|
||||
|
||||
private applyHighlight(entityId: number): void {
|
||||
const es = this.entitySprites.get(entityId);
|
||||
if (!es) return;
|
||||
this.clearHighlight();
|
||||
es.sprite.postFX.addGlow(0xff0000, 2, 0, false, 0.1, 4);
|
||||
this.highlightedSpriteId = entityId;
|
||||
}
|
||||
|
||||
private clearHighlight(): void {
|
||||
if (this.highlightedSpriteId != null) {
|
||||
const es = this.entitySprites.get(this.highlightedSpriteId);
|
||||
if (es) {
|
||||
es.sprite.postFX.clear();
|
||||
}
|
||||
this.highlightedSpriteId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user