cutechicken commited on
Commit
e487b55
Β·
verified Β·
1 Parent(s): 294d74f

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +17 -3
game.js CHANGED
@@ -684,27 +684,41 @@ class Game {
684
  startBGM() {
685
  if (this.bgmPlaying) return;
686
 
 
 
687
  try {
688
  this.bgm = new Audio('sounds/main.ogg');
689
  this.bgm.volume = 0.5;
690
  this.bgm.loop = true;
691
 
 
 
 
 
 
 
 
 
692
  // μ¦‰μ‹œ μž¬μƒ μ‹œλ„
693
  const playPromise = this.bgm.play();
694
 
 
 
695
  if (playPromise !== undefined) {
696
  playPromise.then(() => {
697
  this.bgmPlaying = true;
698
- console.log('BGM μž¬μƒ μ‹œμž‘');
699
  }).catch(error => {
700
- console.log('μžλ™ μž¬μƒμ΄ 차단됨, 클릭 ν›„ μž¬μƒ μ‹œλ„');
 
701
 
702
  // μ‚¬μš©μž μƒν˜Έμž‘μš© ν›„ μž¬μƒ μž¬μ‹œλ„
703
  const tryPlayOnInteraction = () => {
704
  if (!this.bgmPlaying) {
 
705
  this.bgm.play().then(() => {
706
  this.bgmPlaying = true;
707
- console.log('BGM μž¬μƒ μ‹œμž‘ (클릭 ν›„)');
708
  // 이벀트 λ¦¬μŠ€λ„ˆ 제거
709
  document.removeEventListener('click', tryPlayOnInteraction);
710
  document.removeEventListener('keydown', tryPlayOnInteraction);
 
684
  startBGM() {
685
  if (this.bgmPlaying) return;
686
 
687
+ console.log('BGM μ‹œμž‘ μ‹œλ„...');
688
+
689
  try {
690
  this.bgm = new Audio('sounds/main.ogg');
691
  this.bgm.volume = 0.5;
692
  this.bgm.loop = true;
693
 
694
+ console.log('Audio 객체 생성 μ™„λ£Œ');
695
+
696
+ // μ˜€λ””μ˜€ 이벀트 λ¦¬μŠ€λ„ˆ μΆ”κ°€
697
+ this.bgm.addEventListener('loadstart', () => console.log('BGM λ‘œλ”© μ‹œμž‘'));
698
+ this.bgm.addEventListener('canplay', () => console.log('BGM μž¬μƒ κ°€λŠ₯'));
699
+ this.bgm.addEventListener('error', (e) => console.log('BGM μ—λŸ¬:', e));
700
+ this.bgm.addEventListener('loadeddata', () => console.log('BGM 데이터 λ‘œλ“œ μ™„λ£Œ'));
701
+
702
  // μ¦‰μ‹œ μž¬μƒ μ‹œλ„
703
  const playPromise = this.bgm.play();
704
 
705
+ console.log('μž¬μƒ μ‹œλ„ 쀑...');
706
+
707
  if (playPromise !== undefined) {
708
  playPromise.then(() => {
709
  this.bgmPlaying = true;
710
+ console.log('BGM μž¬μƒ μ‹œμž‘ 성곡!');
711
  }).catch(error => {
712
+ console.log('μžλ™ μž¬μƒμ΄ 차단됨:', error);
713
+ console.log('클릭 ν›„ μž¬μƒ μ‹œλ„ λŒ€κΈ° 쀑...');
714
 
715
  // μ‚¬μš©μž μƒν˜Έμž‘μš© ν›„ μž¬μƒ μž¬μ‹œλ„
716
  const tryPlayOnInteraction = () => {
717
  if (!this.bgmPlaying) {
718
+ console.log('μ‚¬μš©μž μƒν˜Έμž‘μš©μœΌλ‘œ BGM μž¬μƒ μ‹œλ„...');
719
  this.bgm.play().then(() => {
720
  this.bgmPlaying = true;
721
+ console.log('BGM μž¬μƒ μ‹œμž‘ 성곡 (클릭 ν›„)!');
722
  // 이벀트 λ¦¬μŠ€λ„ˆ 제거
723
  document.removeEventListener('click', tryPlayOnInteraction);
724
  document.removeEventListener('keydown', tryPlayOnInteraction);