diff --git a/src/core/render/preset/viewport.ts b/src/core/render/preset/viewport.ts index 01603c8..864f3aa 100644 --- a/src/core/render/preset/viewport.ts +++ b/src/core/render/preset/viewport.ts @@ -159,7 +159,7 @@ export class FloorViewport implements ILayerGroupRenderExtends { let yStartTime: number = Date.now(); let ending: boolean = false; // 这个数等于 sinh(2),用这个数的话,可以正好在刚开始移动的时候达到1的斜率,效果会比较好 - const transitionTime = this.hero.speed * 3.626860407847019; + let transitionTime = this.hero.speed * 3.626860407847019; const setTargetX = (x: number, time: number) => { if (x === xTarget) return; @@ -178,6 +178,7 @@ export class FloorViewport implements ILayerGroupRenderExtends { this.hero.off('moveTick', this.movingFramer); } this.movingFramer = () => { + if (this.inTransition) return; const now = Date.now(); if (!this.inMoving && !ending) { setTargetX(0, now); @@ -194,10 +195,7 @@ export class FloorViewport implements ILayerGroupRenderExtends { if (!this.hero.renderable) return; const { x, y } = this.hero.renderable; - const { x: nx, y: ny } = this.getBoundedPosition( - x + this.ox, - y + this.oy - ); + const { x: nx, y: ny } = this.getBoundedPosition(x, y); this.nx = nx; this.ny = ny; @@ -207,6 +205,8 @@ export class FloorViewport implements ILayerGroupRenderExtends { return; } } + // todo: 效果太差了,需要优化 + return; if (this.ox !== xTarget) { const time = transitionTime * Math.abs(xStart - xTarget); const progress = (now - xStartTime) / time; diff --git a/src/game/state/move.ts b/src/game/state/move.ts index 9bbcb5c..1ba8ef3 100644 --- a/src/game/state/move.ts +++ b/src/game/state/move.ts @@ -504,6 +504,8 @@ export class HeroMover extends ObjectMoverBase { viewport.sync('startMove'); } } + } else { + viewport.sync('startMove'); } } @@ -528,7 +530,8 @@ export class HeroMover extends ObjectMoverBase { step: MoveStepDir, controller: IMoveController ): Promise { - const showDir = toDir(this.moveDir); + const showDir = toDir(this.faceDir); + const dir4Move = toDir(this.moveDir); core.setHeroLoc('direction', showDir); const { x, y } = core.status.hero.loc; @@ -549,7 +552,7 @@ export class HeroMover extends ObjectMoverBase { // 检查传送门 if (!this.ignoreTerrain) { - const { portal, data } = this.checkPortal(x, y, showDir); + const { portal, data } = this.checkPortal(x, y, dir4Move); if (portal && data) { this.portalData = data; await this.renderHeroSwap(data); @@ -559,7 +562,7 @@ export class HeroMover extends ObjectMoverBase { const dir = this.moveDir; if (!this.ignoreTerrain) { - const { noPass, canMove } = this.checkCanMove(x, y, showDir); + const { noPass, canMove } = this.checkCanMove(x, y, dir4Move); if (!canMove) { return HeroMoveCode.CannotMove; @@ -603,7 +606,7 @@ export class HeroMover extends ObjectMoverBase { ): Promise { const { x, y } = core.status.hero.loc; const { x: nx, y: ny } = this.nextLoc(x, y, this.moveDir); - const showDir = toDir(this.moveDir); + const showDir = toDir(this.faceDir); // 前方不能移动 if (