File tree 4 files changed +253
-216
lines changed
4 files changed +253
-216
lines changed Original file line number Diff line number Diff line change 3
3
## [ 10.11.0] (melonJS 2) - _ 2022-XX-XX_
4
4
5
5
### Changed
6
+ - Core: refactored Timer into an instantiable class with ` time ` (namespace) now being a default instance of the Timer class
6
7
- Doc: replaced JSDoc by Webdoc for documentation generation (huge thanks to @ShukantPal )
7
8
8
9
### Fixed
Original file line number Diff line number Diff line change 1
1
import { pauseTrack , resumeTrack } from "./../audio/audio.js" ;
2
2
import * as fctUtil from "./../utils/function.js" ;
3
3
import * as event from "./../system/event.js" ;
4
- import timer from "./../system/timer.js" ;
5
4
import * as game from "./../game.js" ;
6
5
import Stage from "./../state/stage.js" ;
7
6
import DefaultLoadingScreen from "./../loader/loadingscreen.js" ;
@@ -41,9 +40,6 @@ var _pauseTime = 0;
41
40
function _startRunLoop ( ) {
42
41
// ensure nothing is running first and in valid state
43
42
if ( ( _animFrameId === - 1 ) && ( _state !== - 1 ) ) {
44
- // reset the timer
45
- timer . reset ( ) ;
46
-
47
43
// start the main loop
48
44
_animFrameId = globalThis . requestAnimationFrame ( _renderFrame ) ;
49
45
}
@@ -56,9 +52,6 @@ function _startRunLoop() {
56
52
function _resumeRunLoop ( ) {
57
53
// ensure game is actually paused and in valid state
58
54
if ( _isPaused && ( _state !== - 1 ) ) {
59
- // reset the timer
60
- timer . reset ( ) ;
61
-
62
55
_isPaused = false ;
63
56
}
64
57
}
@@ -124,6 +117,9 @@ function _switchState(state) {
124
117
// new requested state
125
118
_startRunLoop ( ) ;
126
119
120
+ // publish the pause event
121
+ event . emit ( event . STATE_CHANGE ) ;
122
+
127
123
// execute callback if defined
128
124
if ( _onSwitchComplete ) {
129
125
_onSwitchComplete ( ) ;
Original file line number Diff line number Diff line change @@ -67,6 +67,17 @@ export const STATE_STOP = "me.state.onStop";
67
67
*/
68
68
export const STATE_RESTART = "me.state.onRestart" ;
69
69
70
+ /**
71
+ * event for when the changing to a different stage
72
+ * @public
73
+ * @constant
74
+ * @type {string }
75
+ * @name STATE_CHANGE
76
+ * @memberof event
77
+ * @see event.on
78
+ */
79
+ export const STATE_CHANGE = "me.state.onChange" ;
80
+
70
81
/**
71
82
* event for when the video is initialized<br>
72
83
* Data passed : none <br>
You can’t perform that action at this time.
0 commit comments