优化座驾特效入场标题

This commit is contained in:
pllx
2026-04-30 10:29:11 +08:00
parent 18acd7d890
commit 221f629ec2
12 changed files with 91 additions and 41 deletions
+9 -6
View File
@@ -446,8 +446,9 @@ const Type99AEffect = (() => {
* @param {number} w 画布宽度
* @param {number} h 画布高度
* @param {number} progress 播放进度
* @param {string} title 入场标题
*/
function drawHud(ctx, w, h, progress) {
function drawHud(ctx, w, h, progress, title) {
const enter = Math.min(1, Math.max(0, (progress - 0.14) / 0.2));
const leave = Math.min(1, Math.max(0, (1 - progress) / 0.16));
const alpha = easeInOutSine(enter) * leave;
@@ -461,7 +462,7 @@ const Type99AEffect = (() => {
ctx.fillStyle = "rgba(28,25,23,0.66)";
ctx.strokeStyle = "rgba(253,230,138,0.72)";
ctx.lineWidth = 2;
roundRect(ctx, w * 0.5 - 226, y - 42, 452, 88, 18);
roundRect(ctx, w * 0.5 - 320, y - 46, 640, 96, 18);
ctx.fill();
ctx.stroke();
@@ -469,8 +470,8 @@ const Type99AEffect = (() => {
ctx.font = "700 16px serif";
ctx.fillText("ZTZ-99A ARMORED FORCE", w * 0.5, y - 12);
ctx.fillStyle = "#ffffff";
ctx.font = "900 40px serif";
ctx.fillText("99A主战坦克 重装入场", w * 0.5, y + 28);
ctx.font = "900 38px serif";
ctx.fillText(title, w * 0.5, y + 28, 590);
ctx.restore();
}
@@ -503,13 +504,15 @@ const Type99AEffect = (() => {
*
* @param {HTMLCanvasElement} canvas 全屏特效画布
* @param {Function} onEnd 结束回调
* @param {object} options 特效附加参数
* @returns {{cancel: Function}}
*/
function start(canvas, onEnd) {
function start(canvas, onEnd, options = {}) {
const ctx = canvas.getContext("2d");
const w = canvas.width;
const h = canvas.height;
const dust = createDust(w, h);
const title = String(options.effect_title || "99A主战坦克 重装入场").trim() || "99A主战坦克 重装入场";
const startTime = performance.now();
let animId = null;
let finished = false;
@@ -553,7 +556,7 @@ const Type99AEffect = (() => {
drawDust(ctx, dust, w, progress);
drawShockwave(ctx, w, h, progress);
drawTank(ctx, tankX, tankY, scale, progress);
drawHud(ctx, w, h, progress);
drawHud(ctx, w, h, progress, title);
if (progress < 1) {
animId = requestAnimationFrame(animate);