张延森 3 anni fa
parent
commit
a3177fdfdf
1 ha cambiato i file con 11 aggiunte e 5 eliminazioni
  1. 11
    5
      src/game.js

+ 11
- 5
src/game.js Vedi File

@@ -140,9 +140,12 @@ export default function game({ el, onError, onSuccess }) {
140 140
 
141 141
     const hitted = isHit(currentBullet)
142 142
     if (hitted === 'error') {
143
-      isError = true
144
-      isFinished = true
145
-      onError()
143
+      const t = setTimeout(() => {
144
+        isError = true
145
+        isFinished = true
146
+        onError()
147
+        clearTimeout(t)
148
+      }, 0)
146 149
       return
147 150
     }
148 151
 
@@ -152,8 +155,11 @@ export default function game({ el, onError, onSuccess }) {
152 155
       isShooting = false;
153 156
 
154 157
       if (!clip.length) {
155
-        onSuccess()
156
-        isFinished = true
158
+        const t = setTimeout(() => {
159
+          isFinished = true
160
+          onSuccess()
161
+          clearTimeout(t)
162
+        }, 0)
157 163
       }
158 164
     }
159 165
   }