From 970600f97bed1ab0cdec9dc3de87b3d875496f87 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 3 Oct 2024 17:00:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=93=E5=85=B7=E6=98=BE=E4=BC=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/render/preset/damage.ts | 7 ++++++- src/core/render/preset/layer.ts | 4 ++-- src/game/enemy/damage.ts | 1 + src/plugin/fx/itemDetail.ts | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/render/preset/damage.ts b/src/core/render/preset/damage.ts index 4f7e6f6..6ead4cd 100644 --- a/src/core/render/preset/damage.ts +++ b/src/core/render/preset/damage.ts @@ -496,11 +496,13 @@ export class Damage extends Sprite { // todo: 是否真的需要缓存 // 检查有没有缓存 - const cache = block.cache.get(v * block.cacheDepth); + const cache = block.cache.get(v); if (cache && cache.symbol === cache.canvas.symbol) { ctx.drawImage(cache.canvas.canvas, px, py, size, size); return; } + + this.updateBlock(v, true); this.emit('dirtyUpdate', v); // 否则依次渲染并写入缓存 @@ -512,7 +514,10 @@ export class Damage extends Sprite { temp.size(size, size); const { ctx: ct } = temp; + ct.translate(-px, -py); + const render = this.renderable.get(v); + render?.forEach(v => { if (!v) return; ct.fillStyle = v.color; diff --git a/src/core/render/preset/layer.ts b/src/core/render/preset/layer.ts index ed077d0..c5b52d0 100644 --- a/src/core/render/preset/layer.ts +++ b/src/core/render/preset/layer.ts @@ -341,8 +341,8 @@ export function calNeedRenderOf( const [px3, py3] = Transform.untransformed(transform, w - 1, h - 1); const [px4, py4] = Transform.untransformed(transform, 0, h - 1); - const maxX = block.width * cell; - const maxY = block.height * cell; + const maxX = block.width * cell - 1; + const maxY = block.height * cell - 1; const res: Set = new Set(); // 实际上不太可能一次性渲染非常多的图块,因此不需要非常细致地算出所有的格点,整体包含即可 diff --git a/src/game/enemy/damage.ts b/src/game/enemy/damage.ts index 59234b1..7e83910 100644 --- a/src/game/enemy/damage.ts +++ b/src/game/enemy/damage.ts @@ -690,6 +690,7 @@ export class DamageEnemy { if ( block && block.event.noPass && + block.event.cls !== 'enemys' && block.id !== 141 && block.id !== 151 ) { diff --git a/src/plugin/fx/itemDetail.ts b/src/plugin/fx/itemDetail.ts index b51ffb2..fd0c4bc 100644 --- a/src/plugin/fx/itemDetail.ts +++ b/src/plugin/fx/itemDetail.ts @@ -100,7 +100,7 @@ export class FloorItemDetail implements ILayerGroupRenderExtends { // 预留blockData const [x, y] = this.sprite.block.getBlockXY(width, height); const num = x * y; - for (let i = 0; i < num; i++) { + for (let i = 0; i <= num; i++) { this.blockData.set(i, new Map()); this.detailData.set(i, new Map()); this.dirtyBlock.add(i);