MCPcopy Create free account
hub / github.com/melonjs/melonJS / stop

Function stop

packages/melonjs/src/state/state.ts:307–326  ·  view source on GitHub ↗

* Stop the current stage. * @param [shouldPauseTrack=false] - pause current track on screen stop.

(shouldPauseTrack: boolean = false)

Source from the content-addressed store, hash-verified

305 * @param [shouldPauseTrack=false] - pause current track on screen stop.
306 */
307 stop(shouldPauseTrack: boolean = false): void {
308 // only stop when we are not loading stuff
309 if (_state !== this.LOADING && this.isRunning()) {
310 // caller is taking over — drop any in-flight freeze
311 _cancelFreeze();
312 // stop the main loop
313 _stopRunLoop();
314
315 // current music stop
316 if (shouldPauseTrack) {
317 pauseTrack();
318 }
319
320 // store time when stopped
321 _pauseTime = globalThis.performance.now();
322
323 // publish the stop notification
324 emit(STATE_STOP);
325 }
326 },
327
328 /**
329 * pause the current stage

Callers

nothing calls this directly

Calls 5

pauseTrackFunction · 0.90
emitFunction · 0.90
_cancelFreezeFunction · 0.85
_stopRunLoopFunction · 0.85
isRunningMethod · 0.80

Tested by

no test coverage detected