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);