Browse Source

新增注释

DW-PC\DW 5 years ago
parent
commit
d70cec5efb
2 changed files with 5 additions and 4 deletions
  1. 2 2
      index.js
  2. 3 2
      module/game.js

+ 2 - 2
index.js

@@ -5,7 +5,7 @@ class Index {
     constructor() {
         this.startEle = document.querySelector(".mod-start");
         this.mainEle = document.querySelector(".mod-main");
-        this.videoElement = document.getElementById("cameraVideo");
+        // this.videoElement = document.getElementById("cameraVideo");
         this.gameElement = this.mainEle.querySelector(".mod-game");
         this.decibelStandard = 60; //分贝值,超过这个值才能触发游戏交互
         this.init();
@@ -30,7 +30,7 @@ class Index {
         });
     }
     initMedia() {
-        this.media = new ModuleMedia(this.videoElement);
+        this.media = new ModuleMedia();
     }
     initGame() {
         this.game = new ModuleGame(this.gameElement);

+ 3 - 2
module/game.js

@@ -317,6 +317,7 @@ class Game {
             return;
         }
 
+        //寻找人物是否在地面上方。如果不在,就寻找下一个可能会碰撞的地面
         let index = this.groundData.findIndex(
             ground =>
                 rolePosX >= ground.x && rolePosX <= ground.x + ground.width
@@ -332,7 +333,7 @@ class Game {
                 this.fallDown();
             }
 
-            //在坑里,默认寻找下一个地面作为碰撞检测
+            //寻找下一个地面作为碰撞检测
             index = this.groundData.findIndex(ground => rolePosX <= ground.x);
         }
 
@@ -372,8 +373,8 @@ class Game {
         this.decibel = 0;
         this.decibelArr = [];
         this.roleState = ROLESTATE.RUN;
-        this.app.ticker.remove(this.downLoop, this);
         this.fallingDown = false;
+        this.app.ticker.remove(this.downLoop, this);
     }
 
     //最后即将通关时候,人物开始走动,而不是背景移动。