fea: 优化死亡特效
This commit is contained in:
1 parent
afe2f64b9b
commit
e7200989ab
9 files changed
+373
-94
No files matched your search
+21
-3
@@ -136,10 +136,13 @@ function restart() {
|
||||
G.deaths = d; // 死亡数不重置
|
||||
}
|
||||
|
||||
/** 自杀(IWBT 的 R 键):死后自动回到最近的存档点 */
|
||||
/** R 键 / 触屏重生键:直接重生回最近的存档点——死亡中按 = 立即复活;活着按 = 原地播死亡动画后当帧重生 */
|
||||
function suicide() {
|
||||
if (!G.player || G.state !== 'playing') return;
|
||||
G.player.kill();
|
||||
if (G.player.dead) G.player.respawn();
|
||||
// 活着按:原地播死亡动画(粒子+轻震+冲击环),但不留红叉、不计死亡数,当帧就回存档点——
|
||||
// 不等待,特效由 Level 层留在死亡位置自然播完(重生不清粒子/震屏)
|
||||
else { G.player.deathBurst(); G.player.respawn(); }
|
||||
}
|
||||
|
||||
/** 触屏射击:仅在持枪、未死亡且游戏进行中时发射(受玩家自身冷却限制) */
|
||||
@@ -191,7 +194,7 @@ function resume() { if (G.state === 'paused') { G.state = 'playing'; UI.showGame
|
||||
// ---------------- 更新 ----------------
|
||||
function update() {
|
||||
const P = G.player;
|
||||
// R = 自杀回存档点;Backspace = 整关重开
|
||||
// R = 重生回存档点;Backspace = 整关重开
|
||||
if (Input.hit('suicide')) { suicide(); return; }
|
||||
if (Input.hit('restart')) { restart(); return; }
|
||||
if (Input.hit('pause')) { pause(); return; }
|
||||
@@ -240,6 +243,21 @@ function render() {
|
||||
ctx.restore();
|
||||
L.drawOverlay(ctx, C, t);
|
||||
UI.toast(L.toast || '');
|
||||
// 死亡中:提示手动重生(呼吸闪烁,不抢死亡动画镜头)
|
||||
if (G.state === 'playing' && P.dead) {
|
||||
const blink = Math.sin(t / 12) > -0.3;
|
||||
ctx.save();
|
||||
ctx.textAlign = 'center';
|
||||
ctx.globalAlpha = blink ? 1 : 0.3;
|
||||
ctx.fillStyle = '#ff8fa3';
|
||||
ctx.font = 'bold 20px monospace';
|
||||
ctx.fillText(useTouch ? '按右下角重生键' : '按 R 重生', W / 2, H / 2 - 36);
|
||||
ctx.globalAlpha = 0.7;
|
||||
ctx.fillStyle = '#a8a8c0';
|
||||
ctx.font = '12px monospace';
|
||||
ctx.fillText('Backspace 整关重来', W / 2, H / 2 - 12);
|
||||
ctx.restore();
|
||||
}
|
||||
} else {
|
||||
drawTitleBg(t);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user