From 8440f222aca6dca09bd2a9f38c832b1193b7cfcb Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Tue, 27 Aug 2024 00:23:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=89=E5=BD=B1=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/project/functions.js | 7 ++++--- src/core/fx/shadow.ts | 23 ++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/public/project/functions.js b/public/project/functions.js index dfd2cd8..84bbf52 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -136,15 +136,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { // 重置画布尺寸 core.maps.resizeMap(floorId); + + // ---------- 重绘新地图;这一步将会设置core.status.floorId ---------- // + core.drawMap(floorId); + // 设置勇士的位置 heroLoc.direction = core.turnDirection(heroLoc.direction); core.setHeroLoc('x', heroLoc.x); core.setHeroLoc('y', heroLoc.y); core.setHeroLoc('direction', heroLoc.direction); - // ---------- 重绘新地图;这一步将会设置core.status.floorId ---------- // - core.drawMap(floorId); - // 切换楼层BGM if (core.status.maps[floorId].bgm) { var bgm = core.status.maps[floorId].bgm; diff --git a/src/core/fx/shadow.ts b/src/core/fx/shadow.ts index c89d715..eca55e2 100644 --- a/src/core/fx/shadow.ts +++ b/src/core/fx/shadow.ts @@ -134,17 +134,17 @@ hook.once('reset', () => { }); hook.on('reset', () => { Shadow.update(true); - LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); + LayerShadowExtends.shadowList.forEach(v => v.update()); }) hook.on('setBlock', () => { Shadow.update(true); - LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); + LayerShadowExtends.shadowList.forEach(v => v.update()); }) -hook.on('changingFloor', floorId => { +hook.on('changingFloor', floorId => { Shadow.clearBuffer(); Shadow.update(); setCanvasFilterByFloorId(floorId); - LayerShadowExtends.shadowList.forEach(v => v.sprite.update(v.sprite)); + LayerShadowExtends.shadowList.forEach(v => v.update()); }) // 深度测试着色器 @@ -1305,21 +1305,29 @@ export class LayerShadowExtends implements ILayerRenderExtends { static shadowList: Set = new Set(); id: string = 'shadow'; + layer!: Layer hero!: HeroRenderer sprite!: Sprite; + update() { + this.sprite.update(this.sprite); + } + private onMoveTick = (x: number, y: number) => { const now = Shadow.now(); if (!now) return; - if (now.followHero.size === 0) return; + if (now.followHero.size === 0) return; now.followHero.forEach(v => { now.modifyLight(v, { x: x * 32 + 16, y: y * 32 + 16 }); }); - now.requestRefresh(); - this.sprite.update(this.sprite); + now.requestRefresh(); + + this.layer.requestAfterFrame(() => { + this.sprite.update(this.sprite); + }); } private listen() { @@ -1334,6 +1342,7 @@ export class LayerShadowExtends implements ILayerRenderExtends { return; } this.hero = ex as HeroRenderer; + this.layer = layer; this.listen(); LayerShadowExtends.shadowList.add(this); this.sprite = new Sprite('static', false);