Fix: 烟花/下雨改用clearRect不遮挡背景,雷电次数增至10次更密集

This commit is contained in:
2026-02-27 14:17:56 +08:00
parent 709e0d4975
commit 215fbd7221
3 changed files with 10 additions and 16 deletions
+5 -5
View File
@@ -91,8 +91,8 @@ const LightningEffect = (() => {
*/
function start(canvas, onEnd) {
const ctx = canvas.getContext("2d");
const FLASHES = 5; // 总闪电次数
const DURATION = 5000; // 总时长(ms
const FLASHES = 10; // 总闪电次数(增加密度)
const DURATION = 7000; // 总时长(ms,相应延长
let count = 0;
// 间隔不规则触发多次闪电(模拟真实雷电节奏)
@@ -102,13 +102,13 @@ const LightningEffect = (() => {
setTimeout(() => {
ctx.clearRect(0, 0, canvas.width, canvas.height);
onEnd();
}, 500);
}, 400);
return;
}
_flash(canvas, ctx);
count++;
// 下次闪电间隔:800ms ~ 1200ms 之间随机
const delay = 700 + Math.random() * 500;
// 下次闪电间隔:400ms ~ 800ms 之间随机(更频繁)
const delay = 400 + Math.random() * 400;
setTimeout(nextFlash, delay);
}