// 劍氣特效 (X 型 + 隨機劍鳴 + 擊中特效) document.addEventListener("click", e=>{ // 劍氣裂痕 const slash=document.createElement("div"); slash.className="slash"; slash.style.left=e.pageX-75+"px"; slash.style.top=e.pageY+"px"; document.body.appendChild(slash); setTimeout(()=>slash.remove(),600); // 隨機播放劍鳴 const sounds = [ document.getElementById("sword-sound-1"), document.getElementById("sword-sound-2"), document.getElementById("sword-sound-3") ]; const pick = sounds[Math.floor(Math.random()*sounds.length)]; pick.currentTime=0; pick.play(); // 擊中特效 const el = document.elementFromPoint(e.clientX, e.clientY); if(el && el.tagName !== "BODY" && el.tagName !== "HTML") { // 閃光 const flash=document.createElement("div"); flash.className="hit-flash"; flash.style.left=(e.pageX-40)+"px"; flash.style.top=(e.pageY-40)+"px"; document.body.appendChild(flash); setTimeout(()=>flash.remove(),500); // 元素震動 el.classList.add("shake"); setTimeout(()=>el.classList.remove("shake"),300); } });