Commit 902e3273 authored by 董政锦's avatar 董政锦

fix; 修复 game5 套中圈2种声音;

parent 75312720
...@@ -241,7 +241,8 @@ const hitHandler = (score: number) => { ...@@ -241,7 +241,8 @@ const hitHandler = (score: number) => {
tick.value += score tick.value += score
console.log('[WebSocket] 圈中马!得分:', score, '当前总分:', tick.value) console.log('[WebSocket] 圈中马!得分:', score, '当前总分:', tick.value)
submitScore() submitScore()
playGame1Music() // console.log('[Audio] playGame1Music() 被调用 - 播放 game1.mp3 背景音乐')
// playGame1Music()
} }
if (wechat) { if (wechat) {
......
...@@ -39,13 +39,13 @@ const CIRCLE_THROW_MS = 1200 // 圈圈飞行时长 ...@@ -39,13 +39,13 @@ const CIRCLE_THROW_MS = 1200 // 圈圈飞行时长
const HIT_FADE_MS = 400 // 被套中后马消失延迟 const HIT_FADE_MS = 400 // 被套中后马消失延迟
// ── 难度递增参数:随游戏时间从 0→60s 指数曲线变化 ── // ── 难度递增参数:随游戏时间从 0→60s 指数曲线变化 ──
const HORSE_SPEED_MIN = 80 // px/s 初始速度 const HORSE_SPEED_MIN = 120 // px/s 初始速度(加快)
const HORSE_SPEED_MAX = 200 // px/s 最大速度(60s 时,7倍提升 const HORSE_SPEED_MAX = 250 // px/s 最大速度(提升上限
const SPAWN_MIN_START = 3000 // ms 初始最短生成间隔 const SPAWN_MIN_START = 1500 // ms 初始最短生成间隔(缩短)
const SPAWN_MIN_END = 800 // ms 最终最短生成间隔 const SPAWN_MIN_END = 500 // ms 最终最短生成间隔(缩短)
const SPAWN_MAX_START = 6000 // ms 初始最长生成间隔 const SPAWN_MAX_START = 3000 // ms 初始最长生成间隔(缩短)
const SPAWN_MAX_END = 1800 // ms 最终最长生成间隔 const SPAWN_MAX_END = 1000 // ms 最终最长生成间隔(缩短)
const MAX_HORSES_ON_SCREEN = 8 // 场上最多马匹数 const MAX_HORSES_ON_SCREEN = 10 // 场上最多马匹数(增加)
// 马动画帧率控制(参考 Rank1View:每 N 个 raf tick 切一帧 → ~20fps) // 马动画帧率控制(参考 Rank1View:每 N 个 raf tick 切一帧 → ~20fps)
const HORSE_FRAME_TICK = 3 const HORSE_FRAME_TICK = 3
...@@ -125,6 +125,7 @@ function getAudioContext(): AudioContext { ...@@ -125,6 +125,7 @@ function getAudioContext(): AudioContext {
/** 丢圈"咻"声 — 短促上升频率扫频 */ /** 丢圈"咻"声 — 短促上升频率扫频 */
function playThrowSound() { function playThrowSound() {
console.log('[Audio] playThrowSound - 丢圈音效')
try { try {
const ctx = getAudioContext() const ctx = getAudioContext()
const now = ctx.currentTime const now = ctx.currentTime
...@@ -140,11 +141,13 @@ function playThrowSound() { ...@@ -140,11 +141,13 @@ function playThrowSound() {
gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2) gain.gain.exponentialRampToValueAtTime(0.01, now + 0.2)
osc.start(now) osc.start(now)
osc.stop(now + 0.2) osc.stop(now + 0.2)
} catch { /* ignore audio errors */ } console.log('[Audio] playThrowSound - 音效开始播放, 持续0.2s')
} catch (e) { console.error('[Audio] playThrowSound error', e); }
} }
/** 套中"叮"声 — 两个简短的上升音 */ /** 套中"叮"声 — 两个简短的上升音 */
function playHitSound() { function playHitSound() {
console.log('[Audio] playHitSound - 套中马音效(叮声)')
try { try {
const ctx = getAudioContext() const ctx = getAudioContext()
const now = ctx.currentTime const now = ctx.currentTime
...@@ -159,6 +162,7 @@ function playHitSound() { ...@@ -159,6 +162,7 @@ function playHitSound() {
g1.gain.exponentialRampToValueAtTime(0.01, now + 0.25) g1.gain.exponentialRampToValueAtTime(0.01, now + 0.25)
o1.start(now) o1.start(now)
o1.stop(now + 0.25) o1.stop(now + 0.25)
console.log('[Audio] playHitSound - 第一音 880Hz 开始, 持续0.25s')
// 第二音 1320 Hz 延时 0.08s // 第二音 1320 Hz 延时 0.08s
const o2 = ctx.createOscillator() const o2 = ctx.createOscillator()
const g2 = ctx.createGain() const g2 = ctx.createGain()
...@@ -170,7 +174,8 @@ function playHitSound() { ...@@ -170,7 +174,8 @@ function playHitSound() {
g2.gain.exponentialRampToValueAtTime(0.01, now + 0.35) g2.gain.exponentialRampToValueAtTime(0.01, now + 0.35)
o2.start(now + 0.08) o2.start(now + 0.08)
o2.stop(now + 0.35) o2.stop(now + 0.35)
} catch { /* ignore audio errors */ } console.log('[Audio] playHitSound - 第二音 1320Hz 开始, 持续0.35s (延时0.08s)')
} catch (e) { console.error('[Audio] playHitSound error', e); }
} }
// ── 清理全部音效(组件卸载时) ── // ── 清理全部音效(组件卸载时) ──
...@@ -358,8 +363,8 @@ onMounted(() => { ...@@ -358,8 +363,8 @@ onMounted(() => {
// MobileStage 已完成 3-2-1,游戏直接开始 // MobileStage 已完成 3-2-1,游戏直接开始
prevTs = performance.now() prevTs = performance.now()
spawnHorse() spawnHorse()
setTimeout(spawnHorse, 800) setTimeout(spawnHorse, 300) // 更早生成第二匹马
setTimeout(spawnHorse, 1600) setTimeout(spawnHorse, 600) // 更早生成第三匹马
raf = requestAnimationFrame(loop) raf = requestAnimationFrame(loop)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment