[TIL] 211007

Lee SyongΒ·2021λ…„ 10μ›” 7일
0

TIL

λͺ©λ‘ 보기
50/204
post-thumbnail

πŸ“ 였늘 ν•œ 것

  1. ν”„λ‘œμ„ΈμŠ€ / μ“°λ ˆλ“œ / λ©€ν‹°μ“°λ ˆλ”© / μžλ°”μŠ€ν¬λ¦½νŠΈ 엔진 / call stack / event loop / render sequence / λΈŒλΌμš°μ €κ°€ μ½”λ“œλ₯Ό μ‹€ν–‰ν•˜λŠ” κ³Όμ • / task queue와 microtask queue의 차이 / requestAnimationFrame() / 디버깅 tips (개발자 도ꡬ source νƒ­ ν™œμš© 법)

  2. λ―Έλ‹ˆ κ²Œμž„ μ΅œμ’… μ™„μ„±


πŸ“š 배운 것

1. λ¦¬νŒ©ν† λ§

λ―Έλ‹ˆ κ²Œμž„ μ΅œμ’… μ™„μ„±

1) μžλ°”μŠ€ν¬λ¦½νŠΈμ—μ„œ νƒ€μž… 보μž₯ν•˜κΈ° 2

Object.freeze()λ₯Ό μ΄μš©ν•΄ 인자둜 λ¬Έμžμ—΄ carrotκ³Ό bugκ°€ λ“€μ–΄κ°€λŠ” 뢀뢄을 μˆ˜μ •ν•¨

export const ItemType = Object.freeze({
  carrot: 'carrot',
  bug: 'bug'
});

onItemClick (item) {
  if (!this.started) {
    return;
  }

  if (item === ItemType.carrot) { // 'carrot'을 μˆ˜μ •
    this.showGameLimit(--this.limit);
    if (this.limit === 0) {
      this.stop(Reason.win);
    }
  } else if (item === ItemType.bug) { // 'bug'λ₯Ό μˆ˜μ •
    this.stop(Reason.lose);
  }
}
onFieldClick (event) {
  const target = event.target;

  if (target.matches('.carrot')) {
    target.remove();
    this.callBack && this.callBack(ItemType.carrot); // 'carrot'을 μˆ˜μ •
    playSound(carrotSound);
  } else if (target.matches('.bug')) {
    this.callBack && this.callBack(ItemType.bug); // 'bug'λ₯Ό μˆ˜μ •
  }
}

2. 이둠 곡뢀

κ°•μ˜ μ €μž‘κΆŒ 문제둜 인해 배운 것과 ν•„κΈ° λ‚΄μš©μ€ 캑쳐해 첨뢀함
원본은 κΉƒν—ˆλΈŒ private μ €μž₯μ†Œμ— 올림


✨ 내일 ν•  것

  1. ν•¨μˆ˜ν˜• ν”„λ‘œκ·Έλž˜λ° λ°©μ‹μœΌλ‘œ λ―Έλ‹ˆ κ²Œμž„ μ²˜μŒλΆ€ν„° λ‹€μ‹œ κ΅¬ν˜„ν•΄λ³΄κΈ°
profile
λŠ₯λ™μ μœΌλ‘œ μ‚΄μž, ν–‰λ³΅ν•˜κ²ŒπŸ˜

0개의 λŒ“κΈ€