File tree 1 file changed +25
-0
lines changed 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 8
8
} from "./event.js" ;
9
9
import state from "../state/state.js" ;
10
10
import { clamp } from "../math/math.js" ;
11
+ import { defer } from "./../utils/function.js" ;
11
12
12
13
/**
13
14
* a Timer class to manage timing related function (FPS, Game Tick, Time...)
@@ -182,6 +183,30 @@ class Timer {
182
183
return this . timerId ;
183
184
}
184
185
186
+ /**
187
+ * Cancels a timeout previously established by calling setTimeout().
188
+ * @param timeoutID - ID of the timeout to be cancelled
189
+ */
190
+ clearTimeout ( timeoutID : number ) {
191
+ if ( timeoutID > 0 ) {
192
+ defer ( ( ) => {
193
+ this . clearTimer ( timeoutID ) ;
194
+ } , this ) ;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * cancels the timed, repeating action which was previously established by a call to setInterval().
200
+ * @param intervalID - ID of the interval to be cleared
201
+ */
202
+ clearInterval ( intervalID : number ) {
203
+ if ( intervalID > 0 ) {
204
+ defer ( ( ) => {
205
+ this . clearTimer ( intervalID ) ;
206
+ } , this ) ;
207
+ }
208
+ }
209
+
185
210
/**
186
211
* Return the current timestamp in milliseconds <br>
187
212
* since the game has started or since linux epoch (based on browser support for High Resolution Timer)
You can’t perform that action at this time.
0 commit comments