张延森 пре 3 година
родитељ
комит
b1425dd139
1 измењених фајлова са 5 додато и 2 уклоњено
  1. 5
    2
      src/game.js

+ 5
- 2
src/game.js Прегледај датотеку

@@ -137,6 +137,7 @@ export default function game({ el, center, raduis, onError, onSuccess, onBingo }
137 137
     const { top } = currentBullet.getBoundingClientRect()
138 138
     currentBullet.position = new Two.Vector(currentBullet.position.x, top + speed)
139 139
 
140
+    // 是否击中
140 141
     const hitted = isHit(currentBullet)
141 142
     if (hitted === 'error') {
142 143
       const t = setTimeout(() => {
@@ -148,6 +149,7 @@ export default function game({ el, center, raduis, onError, onSuccess, onBingo }
148 149
       return
149 150
     }
150 151
 
152
+    // 击中之后, 需要挂载轿厢到对应的位置
151 153
     if (hitted) {
152 154
       mountToCage(currentBullet, hitted)
153 155
       currentBullet = null;
@@ -185,9 +187,10 @@ export default function game({ el, center, raduis, onError, onSuccess, onBingo }
185 187
           y >= rect1.top && y <= rect1.bottom;
186 188
     })[0]
187 189
 
188
-    if (!cage) return false;
190
+    if (!cage) return false;  // 未找到对应的目标轿厢
191
+    if (mntMap[cage.id]) return false;  // 已经挂载过轿厢
189 192
 
190
-    return !cage ? false : cage
193
+    return cage
191 194
   }
192 195
   
193 196
   // 重复绘制内容