From 0d498a943724f7d90452860a9d38bcf3e51cca05 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 20 Nov 2024 21:35:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=A7=E5=9C=B0=E5=9B=BE=E8=BE=B9?= =?UTF-8?q?=E7=BC=98=E7=9E=AC=E7=A7=BB=E6=97=B6=E8=A7=86=E8=A7=92=E5=BB=B6?= =?UTF-8?q?=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/render/preset/viewport.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/core/render/preset/viewport.ts b/src/core/render/preset/viewport.ts index c7cc70e..01603c8 100644 --- a/src/core/render/preset/viewport.ts +++ b/src/core/render/preset/viewport.ts @@ -193,8 +193,13 @@ export class FloorViewport implements ILayerGroupRenderExtends { if (!this.hero.renderable) return; - this.nx = this.hero.renderable.x; - this.ny = this.hero.renderable.y; + const { x, y } = this.hero.renderable; + const { x: nx, y: ny } = this.getBoundedPosition( + x + this.ox, + y + this.oy + ); + this.nx = nx; + this.ny = ny; if (ending) { if (this.ox === xTarget && this.oy == yTarget) { @@ -272,27 +277,18 @@ export class FloorViewport implements ILayerGroupRenderExtends { private create() { let nx = this.nx; let ny = this.ny; - let ox = this.ox; - let oy = this.oy; const halfWidth = core._PX_ / 2; const halfHeight = core._PY_ / 2; this.delegation = this.group.delegateTicker(() => { if (!this.enabled) return; - if ( - this.nx === nx && - this.ny === ny && - this.ox === ox && - this.oy === oy - ) { + if (this.nx === nx && this.ny === ny) { return; } const cell = this.group.cellSize; const half = cell / 2; nx = this.nx; ny = this.ny; - ox = this.ox; - oy = this.oy; - const { x: bx, y: by } = this.getBoundedPosition(nx + ox, ny + oy); + const { x: bx, y: by } = this.getBoundedPosition(nx, ny); const rx = bx * cell - halfWidth + half; const ry = by * cell - halfHeight + half; core.bigmap.offsetX = rx;