Enhance PersonChatUI to track characters with parallax animation

- Introduced a Set to keep track of characters that have undergone parallax animation, ensuring that the animation resets only for new speakers.
- Updated the logic to conditionally reset the parallax animation based on whether the speaker has been seen before, improving visual continuity during conversations.
This commit is contained in:
Z. Cliffe Schreuders
2025-11-07 20:37:27 +00:00
parent d36b61f20e
commit 4dd2a839f4

View File

@@ -52,6 +52,7 @@ export default class PersonChatUI {
// State
this.currentSpeaker = null; // Character ID
this.hasContinued = false; // Track if user has clicked continue
this.charactersWithParallax = new Set(); // Track which characters have already had parallax animation
console.log('📱 PersonChatUI created');
}
@@ -289,9 +290,11 @@ export default class PersonChatUI {
this.portraitRenderer.setupSpriteInfo();
// Reset parallax animation for new speaker
if (this.portraitRenderer.backgroundImage) {
// Reset parallax animation only for characters we haven't seen before
const speakerId = characterId || character.id;
if (this.portraitRenderer.backgroundImage && !this.charactersWithParallax.has(speakerId)) {
this.portraitRenderer.resetParallaxAnimation();
this.charactersWithParallax.add(speakerId);
}
this.portraitRenderer.render();