Show ... chat bubble over player when too far from NPC
This commit is contained in:
1 parent
2dde0dfd4f
commit
aece71a0d4
3 files changed
+27
-10
No files matched your search
@@ -385,11 +385,12 @@ class Game {
|
||||
|
||||
/* Player sprite stays horizontally centred; only Y shifts */
|
||||
const p = document.getElementById('map-player');
|
||||
if (p) {
|
||||
const pw = document.getElementById('map-player-wrap');
|
||||
if (p && pw) {
|
||||
const centreX = viewW / 2 - 16;
|
||||
const centreY = viewH * 0.65 + this.state.worldY;
|
||||
p.style.left = centreX + 'px';
|
||||
p.style.bottom = (viewH - centreY - 40) + 'px';
|
||||
pw.style.left = centreX + 'px';
|
||||
pw.style.bottom = (viewH - centreY - 40) + 'px';
|
||||
p.className = `map-player walk-${dir}`;
|
||||
}
|
||||
|
||||
@@ -454,11 +455,20 @@ class Game {
|
||||
|
||||
_talkToNPC() {
|
||||
if (!this._nearNPC()) {
|
||||
this.toast('Walk up to the NPC first!');
|
||||
const bub = document.getElementById('player-bubble');
|
||||
if (bub) {
|
||||
bub.classList.remove('visible');
|
||||
void bub.offsetWidth;
|
||||
bub.classList.add('visible');
|
||||
clearTimeout(this._bubbleTimer);
|
||||
this._bubbleTimer = setTimeout(() => bub.classList.remove('visible'), 1500);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const arrow = document.getElementById('map-dir-arrow');
|
||||
if (arrow) arrow.style.display = 'none';
|
||||
const bub = document.getElementById('player-bubble');
|
||||
if (bub) bub.classList.remove('visible');
|
||||
SFX.encounter();
|
||||
this.startQuestion();
|
||||
}
|
||||
@@ -470,11 +480,11 @@ class Game {
|
||||
const viewH = world ? world.parentElement.offsetHeight : 300;
|
||||
|
||||
const p = document.getElementById('map-player');
|
||||
if (p) {
|
||||
p.style.left = (viewW / 2 - 16) + 'px';
|
||||
p.style.bottom = (viewH * 0.28) + 'px';
|
||||
|
||||
p.className = 'map-player idle';
|
||||
const pw = document.getElementById('map-player-wrap');
|
||||
if (p && pw) {
|
||||
pw.style.left = (viewW / 2 - 16) + 'px';
|
||||
pw.style.bottom = (viewH * 0.28) + 'px';
|
||||
p.className = 'map-player idle';
|
||||
}
|
||||
this._applyCamera();
|
||||
const hint = document.getElementById('map-talk-hint');
|
||||
|
||||
Reference in new issue
Block a user