체력바 (고스트 딜레이)

Health Bar (Delayed Ghost Bar)

피격 시 실제 체력은 즉시 줄고, 옅은 색 "고스트" 막대가 한 박자 늦게 따라 줄어들며 얼마나 깎였는지 보여주는 체력바.

다른 이름: 고스트 바Damage delay barHP 바
···
html
<div class="hbwrap"><div class="hplabel">HP</div><div class="hbar"><div class="ghost" id="ghost"></div><div class="real" id="real"></div></div><div class="hbnum" id="hbnum">100</div></div>
css
.hbwrap{width:min(86%,320px);display:flex;flex-direction:column;gap:6px}
.hplabel{font:700 clamp(9px,2.8vmin,12px) monospace;color:var(--muted);letter-spacing:.08em}
.hbar{position:relative;height:clamp(14px,6.5vmin,22px);border-radius:6px;background:color-mix(in srgb,var(--fg) 12%,transparent);border:1px solid var(--line);overflow:hidden}
.ghost,.real{position:absolute;inset:0;transform-origin:left}
.ghost{background:color-mix(in srgb,var(--accent-2) 42%,var(--bg));transition:transform .6s cubic-bezier(.2,.8,.2,1) .35s}
.real{background:var(--accent-2);transition:transform .12s ease-out}
.hbnum{align-self:flex-end;font:700 clamp(11px,3.2vmin,13px) monospace;color:var(--fg)}
js
const real=document.getElementById('real');
const ghost=document.getElementById('ghost');
const num=document.getElementById('hbnum');
function setHp(v){
  const hp=Math.max(0,Math.min(1,v));
  real.style.transform='scaleX('+hp+')';
  ghost.style.transform='scaleX('+hp+')';
  num.textContent=Math.round(hp*100);
}
setHp(1);
const seq=[0.68,0.4,0.16,1];
let i=0;
function step(){
  setHp(seq[i]);
  const delay = i===seq.length-1 ? 1500 : 1050;
  i=(i+1)%seq.length;
  setTimeout(step, delay);
}
setTimeout(step, 900);

체력바는 보통 레이어 두 장으로 만든다. 위에 있는 진한 색 fill이 즉시 새 체력 값으로 줄어들고, 그 뒤에 깔린 옅은(고스트) fill은 transition-delay를 걸어 0.3~0.6초 뒤에 천천히 따라 줄어든다. 그 사이에 남는 색 차이 구간이 "방금 깎인 양"을 그대로 보여준다.

이 딜레이가 없으면 큰 데미지를 맞아도 숫자만 훅 바뀌고 지나가서 타격감이 약하다. 고스트 바 구간이 눈에 남는 시간(잔상)만큼 플레이어는 "많이 맞았다"는 걸 체감한다. 반대로 체력을 회복할 때는 고스트가 즉시 따라오게 하거나 생략해도 된다 — 회복은 굳이 늦출 이유가 없다.

색은 초록→노랑→빨강처럼 잔여 비율에 따라 바꾸는 경우가 많은데, 임계값을 너무 촘촘히 나누면 오히려 산만하다. 보통 50%, 25% 두 구간 정도면 충분하다.

언제 쓰나

체력·보스 페이즈 게이지처럼 값이 갑자기 크게 떨어지는 수치. 서서히 바뀌는 값(경험치 등)에는 고스트가 불필요하다.