@vpmedia/phaser 1.115.0 → 1.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/index.js +56 -96
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts.map +1 -1
  4. package/dist/phaser/core/animation_manager.d.ts +15 -14
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  7. package/dist/phaser/core/array_set.d.ts.map +1 -1
  8. package/dist/phaser/core/cache.d.ts +10 -9
  9. package/dist/phaser/core/cache.d.ts.map +1 -1
  10. package/dist/phaser/core/device_util.d.ts.map +1 -1
  11. package/dist/phaser/core/dom.d.ts.map +1 -1
  12. package/dist/phaser/core/factory.d.ts.map +1 -1
  13. package/dist/phaser/core/game.d.ts.map +1 -1
  14. package/dist/phaser/core/input.d.ts +20 -20
  15. package/dist/phaser/core/input.d.ts.map +1 -1
  16. package/dist/phaser/core/input_handler.d.ts +11 -13
  17. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  18. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  20. package/dist/phaser/core/input_pointer.d.ts +19 -8
  21. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  22. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  23. package/dist/phaser/core/loader.d.ts.map +1 -1
  24. package/dist/phaser/core/raf.d.ts.map +1 -1
  25. package/dist/phaser/core/scale_manager.d.ts +38 -13
  26. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  27. package/dist/phaser/core/scene.d.ts.map +1 -1
  28. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  29. package/dist/phaser/core/signal.d.ts.map +1 -1
  30. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  31. package/dist/phaser/core/sound.d.ts +2 -2
  32. package/dist/phaser/core/sound.d.ts.map +1 -1
  33. package/dist/phaser/core/sound_manager.d.ts +24 -22
  34. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  35. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  36. package/dist/phaser/core/stage.d.ts.map +1 -1
  37. package/dist/phaser/core/time.d.ts.map +1 -1
  38. package/dist/phaser/core/timer.d.ts +1 -1
  39. package/dist/phaser/core/timer.d.ts.map +1 -1
  40. package/dist/phaser/core/tween.d.ts.map +1 -1
  41. package/dist/phaser/core/tween_data.d.ts +26 -26
  42. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  43. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  44. package/dist/phaser/core/world.d.ts.map +1 -1
  45. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  46. package/dist/phaser/display/button.d.ts.map +1 -1
  47. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  48. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  49. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  51. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  53. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  55. package/dist/phaser/display/display_object.d.ts.map +1 -1
  56. package/dist/phaser/display/graphics.d.ts.map +1 -1
  57. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  58. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  59. package/dist/phaser/display/group.d.ts.map +1 -1
  60. package/dist/phaser/display/image.d.ts +2 -2
  61. package/dist/phaser/display/image.d.ts.map +1 -1
  62. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  63. package/dist/phaser/display/text.d.ts.map +1 -1
  64. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  65. package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
  66. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  67. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  68. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  69. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
  70. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  71. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  73. package/dist/phaser/display/webgl/graphics.d.ts +9 -7
  74. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  76. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  78. package/dist/phaser/display/webgl/renderer.d.ts +12 -10
  79. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  80. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  82. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  84. package/dist/phaser/display/webgl/texture.d.ts +18 -33
  85. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  86. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  88. package/dist/phaser/geom/circle.d.ts.map +1 -1
  89. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  90. package/dist/phaser/geom/line.d.ts.map +1 -1
  91. package/dist/phaser/geom/matrix.d.ts +1 -1
  92. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  93. package/dist/phaser/geom/point.d.ts.map +1 -1
  94. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  95. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  96. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  97. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  98. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  99. package/dist/phaser/geom/util/line.d.ts +5 -4
  100. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  101. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  102. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  103. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/rectangle.d.ts +10 -1
  105. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/phaser/core/animation.ts +20 -20
  109. package/src/phaser/core/animation_manager.ts +27 -24
  110. package/src/phaser/core/animation_parser.ts +2 -2
  111. package/src/phaser/core/array_set.ts +7 -7
  112. package/src/phaser/core/cache.ts +55 -51
  113. package/src/phaser/core/callback_context.test.ts +70 -0
  114. package/src/phaser/core/device_util.ts +13 -13
  115. package/src/phaser/core/dom.ts +26 -22
  116. package/src/phaser/core/factory.ts +6 -6
  117. package/src/phaser/core/game.ts +10 -10
  118. package/src/phaser/core/input.ts +37 -39
  119. package/src/phaser/core/input_handler.ts +90 -93
  120. package/src/phaser/core/input_mouse.ts +19 -19
  121. package/src/phaser/core/input_mspointer.ts +15 -15
  122. package/src/phaser/core/input_pointer.ts +37 -28
  123. package/src/phaser/core/input_touch.ts +17 -17
  124. package/src/phaser/core/loader.ts +52 -52
  125. package/src/phaser/core/loader_parser.ts +3 -3
  126. package/src/phaser/core/raf.ts +3 -3
  127. package/src/phaser/core/scale_manager.ts +86 -67
  128. package/src/phaser/core/scene.ts +7 -7
  129. package/src/phaser/core/scene_manager.ts +16 -16
  130. package/src/phaser/core/signal.ts +29 -19
  131. package/src/phaser/core/signal_binding.ts +4 -4
  132. package/src/phaser/core/sound.ts +17 -17
  133. package/src/phaser/core/sound_manager.ts +71 -72
  134. package/src/phaser/core/sound_sprite.ts +1 -1
  135. package/src/phaser/core/stage.ts +7 -7
  136. package/src/phaser/core/time.ts +16 -16
  137. package/src/phaser/core/timer.ts +36 -26
  138. package/src/phaser/core/tween.ts +23 -23
  139. package/src/phaser/core/tween_data.ts +41 -37
  140. package/src/phaser/core/tween_manager.ts +11 -11
  141. package/src/phaser/core/world.ts +1 -1
  142. package/src/phaser/display/bitmap_text.ts +13 -13
  143. package/src/phaser/display/button.ts +13 -13
  144. package/src/phaser/display/canvas/buffer.ts +3 -3
  145. package/src/phaser/display/canvas/graphics.ts +3 -3
  146. package/src/phaser/display/canvas/masker.ts +2 -2
  147. package/src/phaser/display/canvas/pool.ts +6 -6
  148. package/src/phaser/display/canvas/renderer.ts +6 -6
  149. package/src/phaser/display/canvas/tinter.ts +39 -8
  150. package/src/phaser/display/canvas/util.ts +15 -9
  151. package/src/phaser/display/display_object.ts +38 -38
  152. package/src/phaser/display/graphics.ts +30 -30
  153. package/src/phaser/display/graphics_data.ts +1 -1
  154. package/src/phaser/display/graphics_data_util.ts +1 -1
  155. package/src/phaser/display/group.ts +16 -16
  156. package/src/phaser/display/image.ts +30 -26
  157. package/src/phaser/display/sprite_util.ts +12 -4
  158. package/src/phaser/display/text.ts +55 -55
  159. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  160. package/src/phaser/display/webgl/base_texture.ts +22 -18
  161. package/src/phaser/display/webgl/blend_manager.ts +3 -3
  162. package/src/phaser/display/webgl/earcut.ts +3 -3
  163. package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
  164. package/src/phaser/display/webgl/filter_manager.ts +7 -7
  165. package/src/phaser/display/webgl/filter_texture.ts +3 -3
  166. package/src/phaser/display/webgl/graphics.ts +43 -41
  167. package/src/phaser/display/webgl/graphics_data.ts +2 -2
  168. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  169. package/src/phaser/display/webgl/render_texture.ts +6 -6
  170. package/src/phaser/display/webgl/renderer.ts +20 -25
  171. package/src/phaser/display/webgl/shader/normal.ts +3 -3
  172. package/src/phaser/display/webgl/shader_manager.ts +2 -2
  173. package/src/phaser/display/webgl/sprite_batch.ts +9 -9
  174. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  175. package/src/phaser/display/webgl/texture.ts +23 -42
  176. package/src/phaser/display/webgl/texture_util.ts +2 -2
  177. package/src/phaser/display/webgl/util.ts +11 -7
  178. package/src/phaser/geom/circle.ts +21 -21
  179. package/src/phaser/geom/ellipse.ts +7 -7
  180. package/src/phaser/geom/line.ts +29 -29
  181. package/src/phaser/geom/matrix.ts +13 -13
  182. package/src/phaser/geom/point.ts +36 -30
  183. package/src/phaser/geom/polygon.ts +6 -6
  184. package/src/phaser/geom/rectangle.ts +42 -42
  185. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  186. package/src/phaser/geom/util/circle.ts +7 -7
  187. package/src/phaser/geom/util/ellipse.ts +1 -1
  188. package/src/phaser/geom/util/line.ts +13 -5
  189. package/src/phaser/geom/util/matrix.ts +3 -3
  190. package/src/phaser/geom/util/point.ts +20 -20
  191. package/src/phaser/geom/util/polygon.ts +1 -1
  192. package/src/phaser/geom/util/rectangle.ts +34 -17
  193. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
@@ -14,24 +14,24 @@ import { SoundSprite } from './sound_sprite.js';
14
14
 
15
15
  export class SoundManager {
16
16
  public game!: Game;
17
- public onChange!: any;
17
+ public onChange!: Signal;
18
18
  public context!: AudioContext | null;
19
- public baseLatency!: any;
20
- public noAudio!: any;
21
- public type!: any;
22
- public connectToMaster!: any;
23
- public isLocked!: any;
24
- public _codeMuted!: any;
25
- public _muted!: any;
26
- public _unlockSource!: any;
27
- public _volume!: any;
28
- public _sounds!: any;
29
- public _watchList!: any;
30
- public _watching!: any;
31
- public _watchCallback!: any;
32
- public _watchContext!: any;
33
- public masterGain!: any;
34
- public _muteVolume!: any;
19
+ public baseLatency!: number;
20
+ public noAudio!: boolean;
21
+ public type!: number;
22
+ public connectToMaster!: boolean;
23
+ public isLocked!: boolean;
24
+ public _codeMuted!: boolean;
25
+ public _muted!: boolean;
26
+ public _unlockSource!: AudioBufferSourceNode | null;
27
+ public _volume!: number;
28
+ public _sounds!: Sound[];
29
+ public _watchList!: ArraySet;
30
+ public _watching!: boolean;
31
+ public _watchCallback!: Function | null;
32
+ public _watchContext!: unknown;
33
+ public masterGain!: GainNode;
34
+ public _muteVolume!: number;
35
35
  /**
36
36
  * Creates a new SoundManager instance.
37
37
  * @param {Game} game - Reference to the Phaser Game instance.
@@ -62,8 +62,8 @@ export class SoundManager {
62
62
  /**
63
63
  * Initializes the sound manager and sets up audio context.
64
64
  */
65
- public boot() {
66
- const setAudioDisabledState = () => {
65
+ public boot(): void {
66
+ const setAudioDisabledState = (): void => {
67
67
  this.type = AUDIO_DISABLED;
68
68
  this.noAudio = true;
69
69
  this.isLocked = false;
@@ -120,7 +120,7 @@ export class SoundManager {
120
120
  /**
121
121
  * Handles page lifecycle changes for audio management.
122
122
  */
123
- public onPageLifecycleChange = () => {
123
+ public onPageLifecycleChange = (): void => {
124
124
  if (!document.hidden) {
125
125
  this.checkUnlockHandlers();
126
126
  }
@@ -129,7 +129,7 @@ export class SoundManager {
129
129
  /**
130
130
  * Handles audio context state changes.
131
131
  */
132
- public onContextStateChange = () => {
132
+ public onContextStateChange = (): void => {
133
133
  this.game.logger.info('onContextStateChange', {
134
134
  state: this.context!.state,
135
135
  isLocked: this.isLocked,
@@ -140,7 +140,7 @@ export class SoundManager {
140
140
  /**
141
141
  * Checks if audio unlock handlers need to be added or removed.
142
142
  */
143
- public checkUnlockHandlers = () => {
143
+ public checkUnlockHandlers = (): void => {
144
144
  this.game.logger.info('checkUnlockHandlers', {
145
145
  state: this.context!.state,
146
146
  isLocked: this.isLocked,
@@ -155,7 +155,7 @@ export class SoundManager {
155
155
  /**
156
156
  * Adds event listeners to unlock audio context.
157
157
  */
158
- public addUnlockHandlers = () => {
158
+ public addUnlockHandlers = (): void => {
159
159
  this.isLocked = true;
160
160
  this.game.logger.info('addUnlockHandlers', {
161
161
  state: this.context!.state,
@@ -169,7 +169,7 @@ export class SoundManager {
169
169
  /**
170
170
  * Removes event listeners that unlock audio context.
171
171
  */
172
- public removeUnlockHandlers = () => {
172
+ public removeUnlockHandlers = (): void => {
173
173
  this.isLocked = false;
174
174
  this.game.logger.info('removeUnlockHandlers', {
175
175
  state: this.context!.state,
@@ -184,7 +184,7 @@ export class SoundManager {
184
184
  * Handles unlock events to resume audio context.
185
185
  * @param {Event} event - The DOM event that triggered the unlock.
186
186
  */
187
- public onUnlockEvent = (event: Event) => {
187
+ public onUnlockEvent = (event: Event): void => {
188
188
  const initialState = this.context!.state;
189
189
  if (initialState !== 'suspended' && initialState !== 'interrupted') {
190
190
  this.game.logger.info('onUnlockResumeDenied', {
@@ -201,7 +201,7 @@ export class SoundManager {
201
201
  event,
202
202
  });
203
203
  this.context!.resume()
204
- .then(() => {
204
+ .then((): void => {
205
205
  this.game.logger.info('onContextResumeResult', {
206
206
  initialState,
207
207
  state: this.context!.state,
@@ -209,7 +209,7 @@ export class SoundManager {
209
209
  });
210
210
  this.removeUnlockHandlers();
211
211
  })
212
- .catch((error: unknown) => {
212
+ .catch((error: unknown): void => {
213
213
  this.game.logger.info('onContextResumeReject', {
214
214
  initialState,
215
215
  state: this.context!.state,
@@ -227,13 +227,13 @@ export class SoundManager {
227
227
  /**
228
228
  * Stops all sounds in the manager.
229
229
  */
230
- public stopAll() {
230
+ public stopAll(): void {
231
231
  if (this.noAudio) {
232
232
  return;
233
233
  }
234
- for (let i = 0; i < this._sounds.length; i += 1) {
235
- if (this._sounds[i]) {
236
- this._sounds[i].stop();
234
+ for (const sound of this._sounds) {
235
+ if (sound) {
236
+ sound.stop();
237
237
  }
238
238
  }
239
239
  }
@@ -241,13 +241,13 @@ export class SoundManager {
241
241
  /**
242
242
  * Pauses all sounds in the manager.
243
243
  */
244
- public pauseAll() {
244
+ public pauseAll(): void {
245
245
  if (this.noAudio) {
246
246
  return;
247
247
  }
248
- for (let i = 0; i < this._sounds.length; i += 1) {
249
- if (this._sounds[i]) {
250
- this._sounds[i].pause();
248
+ for (const sound of this._sounds) {
249
+ if (sound) {
250
+ sound.pause();
251
251
  }
252
252
  }
253
253
  }
@@ -255,13 +255,13 @@ export class SoundManager {
255
255
  /**
256
256
  * Resumes all sounds in the manager.
257
257
  */
258
- public resumeAll() {
258
+ public resumeAll(): void {
259
259
  if (this.noAudio) {
260
260
  return;
261
261
  }
262
- for (let i = 0; i < this._sounds.length; i += 1) {
263
- if (this._sounds[i]) {
264
- this._sounds[i].resume();
262
+ for (const sound of this._sounds) {
263
+ if (sound) {
264
+ sound.resume();
265
265
  }
266
266
  }
267
267
  }
@@ -270,7 +270,7 @@ export class SoundManager {
270
270
  * Decodes an audio file for playback.
271
271
  * @param {string} key - The key of the sound to decode.
272
272
  */
273
- public decode(key: string) {
273
+ public decode(key: string): void {
274
274
  const soundData = this.game.cache.getSoundData(key);
275
275
  if (!soundData) {
276
276
  return;
@@ -280,14 +280,14 @@ export class SoundManager {
280
280
  }
281
281
  this.game.cache.updateSound(key, 'isDecoding', true);
282
282
  this.context!.decodeAudioData(soundData)
283
- .then((buffer: AudioBuffer) => {
283
+ .then((buffer: AudioBuffer): void => {
284
284
  this.game.cache.decodedSound(key, buffer);
285
285
  })
286
- .catch((error: unknown) => {
286
+ .catch((error: unknown): void => {
287
287
  const typedError = error instanceof Error ? error : new Error(String(error));
288
288
  this.game.logger.fatal('SoundManager', { error: typedError, tags: { 'asset.key': key } });
289
289
  if (typedError.name === 'InvalidStateError') {
290
- addPageLifecycleCallback(PAGE_LIFECYCLE_STATE_ACTIVE, () => {
290
+ addPageLifecycleCallback(PAGE_LIFECYCLE_STATE_ACTIVE, (): void => {
291
291
  this.decode(key);
292
292
  });
293
293
  } else if (typedError.name === 'EncodingError') {
@@ -302,18 +302,17 @@ export class SoundManager {
302
302
  * @param {Function} callback - The callback function to call when all files are decoded.
303
303
  * @param {object} callbackContext - The context in which to call the callback.
304
304
  */
305
- public setDecodedCallback(files: any, callback: Function, callbackContext: unknown) {
306
- if (typeof files === 'string') {
307
- files = [files];
308
- }
305
+ public setDecodedCallback(
306
+ files: string | string[] | Sound | Sound[],
307
+ callback: Function,
308
+ callbackContext: unknown
309
+ ): void {
310
+ const candidates: (string | Sound)[] = typeof files === 'string' ? [files] : Array.isArray(files) ? files : [files];
309
311
  this._watchList.reset();
310
- for (let i = 0; i < files.length; i += 1) {
311
- if (files[i] instanceof Sound) {
312
- if (!this.game.cache.isSoundDecoded(files[i].key)) {
313
- this._watchList.add(files[i].key);
314
- }
315
- } else if (!this.game.cache.isSoundDecoded(files[i])) {
316
- this._watchList.add(files[i]);
312
+ for (const file of candidates) {
313
+ const key = file instanceof Sound ? file.key : file;
314
+ if (!this.game.cache.isSoundDecoded(key)) {
315
+ this._watchList.add(key);
317
316
  }
318
317
  }
319
318
  // All decoded already?
@@ -330,12 +329,12 @@ export class SoundManager {
330
329
  /**
331
330
  * Updates the sound manager state.
332
331
  */
333
- public update() {
332
+ public update(): void {
334
333
  if (this.noAudio) {
335
334
  return;
336
335
  }
337
- for (let i = 0; i < this._sounds.length; i += 1) {
338
- this._sounds[i].update();
336
+ for (const sound of this._sounds) {
337
+ sound.update();
339
338
  }
340
339
  if (this._watching) {
341
340
  let key = this._watchList.first;
@@ -348,7 +347,7 @@ export class SoundManager {
348
347
  if (this._watchList.total === 0) {
349
348
  this.game.logger.info('All sounds decoded');
350
349
  this._watching = false;
351
- this._watchCallback.call(this._watchContext);
350
+ this._watchCallback?.call(this._watchContext);
352
351
  }
353
352
  }
354
353
  }
@@ -361,7 +360,7 @@ export class SoundManager {
361
360
  * @param {boolean} connect - Whether to connect to the master gain node.
362
361
  * @returns {Sound} The created Sound object.
363
362
  */
364
- public add(key: string, volume = 1, loop = false, connect: boolean = this.connectToMaster) {
363
+ public add(key: string, volume = 1, loop = false, connect: boolean = this.connectToMaster): Sound {
365
364
  const sound = new Sound(this.game, key, volume, loop, connect);
366
365
  this._sounds.push(sound);
367
366
  return sound;
@@ -372,7 +371,7 @@ export class SoundManager {
372
371
  * @param {string} key - The key of the sound sprite to add.
373
372
  * @returns {SoundSprite} The created SoundSprite object.
374
373
  */
375
- public addSprite(key: string) {
374
+ public addSprite(key: string): SoundSprite {
376
375
  return new SoundSprite(this.game, key);
377
376
  }
378
377
 
@@ -381,12 +380,12 @@ export class SoundManager {
381
380
  * @param {Sound | null | undefined} sound - The sound object to remove.
382
381
  * @returns {boolean} True if the sound was removed, false otherwise.
383
382
  */
384
- public remove(sound: Sound | null | undefined) {
383
+ public remove(sound: Sound | null | undefined): boolean {
385
384
  let i = this._sounds.length;
386
385
  while (i) {
387
386
  i -= 1;
388
387
  if (this._sounds[i] === sound) {
389
- this._sounds[i].destroy(false);
388
+ this._sounds[i]!.destroy(false);
390
389
  this._sounds.splice(i, 1);
391
390
  return true;
392
391
  }
@@ -399,13 +398,13 @@ export class SoundManager {
399
398
  * @param {string} key - The key of sounds to remove.
400
399
  * @returns {number} The number of sounds removed.
401
400
  */
402
- public removeByKey(key: string) {
401
+ public removeByKey(key: string): number {
403
402
  let i = this._sounds.length;
404
403
  let removed = 0;
405
404
  while (i) {
406
405
  i -= 1;
407
- if (this._sounds[i].key === key) {
408
- this._sounds[i].destroy(false);
406
+ if (this._sounds[i]!.key === key) {
407
+ this._sounds[i]!.destroy(false);
409
408
  this._sounds.splice(i, 1);
410
409
  removed += 1;
411
410
  }
@@ -420,7 +419,7 @@ export class SoundManager {
420
419
  * @param {boolean} loop - Whether the sound should loop.
421
420
  * @returns {Sound} The created Sound object, or null if audio is disabled.
422
421
  */
423
- public play(key: string, volume = 1, loop = false) {
422
+ public play(key: string, volume = 1, loop = false): Sound | null {
424
423
  if (this.noAudio) {
425
424
  return null;
426
425
  }
@@ -432,7 +431,7 @@ export class SoundManager {
432
431
  /**
433
432
  * Mutes all sounds in the manager.
434
433
  */
435
- public setMute() {
434
+ public setMute(): void {
436
435
  if (this._muted) {
437
436
  return;
438
437
  }
@@ -447,7 +446,7 @@ export class SoundManager {
447
446
  /**
448
447
  * Unmutes all sounds in the manager.
449
448
  */
450
- public unsetMute() {
449
+ public unsetMute(): void {
451
450
  if (!this._muted || this._codeMuted) {
452
451
  return;
453
452
  }
@@ -461,11 +460,11 @@ export class SoundManager {
461
460
  /**
462
461
  * Destroys the sound manager and cleans up resources.
463
462
  */
464
- public destroy() {
463
+ public destroy(): void {
465
464
  this.stopAll();
466
- for (let i = 0; i < this._sounds.length; i += 1) {
467
- if (this._sounds[i]) {
468
- this._sounds[i].destroy();
465
+ for (const sound of this._sounds) {
466
+ if (sound) {
467
+ sound.destroy();
469
468
  }
470
469
  }
471
470
  this._sounds = [];
@@ -46,7 +46,7 @@ export class SoundSprite {
46
46
  * TBD.
47
47
  * @param {string} marker - TBD.
48
48
  */
49
- public stop(marker: string) {
49
+ public stop(marker: string): void {
50
50
  if (!marker) {
51
51
  for (const key in this.sounds) {
52
52
  this.sounds[key].stop();
@@ -40,7 +40,7 @@ export class Stage extends DisplayObject {
40
40
  * Sets the background color of the stage.
41
41
  * @param {number} color - The color to set as the background.
42
42
  */
43
- public setBackgroundColor(color: number) {
43
+ public setBackgroundColor(color: number): void {
44
44
  if (this.game.config.transparent) {
45
45
  return;
46
46
  }
@@ -55,7 +55,7 @@ export class Stage extends DisplayObject {
55
55
  /**
56
56
  * Initializes the stage after game creation.
57
57
  */
58
- public boot() {
58
+ public boot(): void {
59
59
  setUserSelect(this.game.canvas, 'none');
60
60
  setTouchAction(this.game.canvas, 'none');
61
61
  }
@@ -63,7 +63,7 @@ export class Stage extends DisplayObject {
63
63
  /**
64
64
  * Pre-updates the stage and its children.
65
65
  */
66
- public override preUpdate() {
66
+ public override preUpdate(): void {
67
67
  this.currentRenderOrderID = 0;
68
68
  // This can't loop in reverse, we need the renderOrderID to be in sequence
69
69
  for (let i = 0; i < this.children.length; i += 1) {
@@ -74,7 +74,7 @@ export class Stage extends DisplayObject {
74
74
  /**
75
75
  * Updates the stage and its children.
76
76
  */
77
- public override update() {
77
+ public override update(): void {
78
78
  let i = this.children.length;
79
79
  while (i) {
80
80
  i -= 1;
@@ -85,7 +85,7 @@ export class Stage extends DisplayObject {
85
85
  /**
86
86
  * Post-updates the stage and its children.
87
87
  */
88
- public override postUpdate() {
88
+ public override postUpdate(): void {
89
89
  for (let i = 0; i < this.children.length; i += 1) {
90
90
  this.children[i]!.postUpdate();
91
91
  }
@@ -106,7 +106,7 @@ export class Stage extends DisplayObject {
106
106
  /**
107
107
  * Destroys the stage and cleans up resources.
108
108
  */
109
- public override destroy() {
109
+ public override destroy(): void {
110
110
  this.exists = false;
111
111
  this.game = null!;
112
112
  this.worldTransform = null;
@@ -132,7 +132,7 @@ export class Stage extends DisplayObject {
132
132
  * Gets whether texture smoothing is enabled.
133
133
  * @returns {boolean} True if texture smoothing is enabled, false otherwise.
134
134
  */
135
- public get smoothed() {
135
+ public get smoothed(): boolean {
136
136
  return globalThis.PhaserRegistry.TEXTURE_SCALE_MODE === SCALE_LINEAR;
137
137
  }
138
138
 
@@ -66,7 +66,7 @@ export class Time {
66
66
  /**
67
67
  * Initializes the time manager and starts tracking time.
68
68
  */
69
- public boot() {
69
+ public boot(): void {
70
70
  this._started = Date.now();
71
71
  this.time = Date.now();
72
72
  this.events.start();
@@ -78,7 +78,7 @@ export class Time {
78
78
  * @param {Timer} timer - The Timer to add.
79
79
  * @returns {Timer} The added Timer object.
80
80
  */
81
- public add(timer: Timer) {
81
+ public add(timer: Timer): Timer {
82
82
  this._timers.push(timer);
83
83
  return timer;
84
84
  }
@@ -88,7 +88,7 @@ export class Time {
88
88
  * @param {boolean} autoDestroy - Whether the timer should be automatically destroyed when it completes.
89
89
  * @returns {Timer} The created Timer object.
90
90
  */
91
- public create(autoDestroy = true) {
91
+ public create(autoDestroy = true): Timer {
92
92
  const timer = new Timer(this.game, autoDestroy);
93
93
  this._timers.push(timer);
94
94
  return timer;
@@ -97,7 +97,7 @@ export class Time {
97
97
  /**
98
98
  * Removes all timers from the Time manager.
99
99
  */
100
- public removeAll() {
100
+ public removeAll(): void {
101
101
  for (const timer of this._timers) {
102
102
  timer.destroy();
103
103
  }
@@ -108,7 +108,7 @@ export class Time {
108
108
  /**
109
109
  * Refreshes the time tracking values.
110
110
  */
111
- public refresh() {
111
+ public refresh(): void {
112
112
  const previousDateNow = this.time;
113
113
  // this.time always holds a Date.now value
114
114
  this.time = Date.now();
@@ -120,7 +120,7 @@ export class Time {
120
120
  * Updates the Time manager with a new timestamp.
121
121
  * @param {number} time - The new timestamp to use for updating.
122
122
  */
123
- public update(time: number) {
123
+ public update(time: number): void {
124
124
  const previousDateNow = this.time;
125
125
  // this.time always holds a Date.now value
126
126
  this.time = Date.now();
@@ -149,7 +149,7 @@ export class Time {
149
149
  /**
150
150
  * Updates all timers managed by the Time manager.
151
151
  */
152
- public updateTimers() {
152
+ public updateTimers(): void {
153
153
  let i = 0;
154
154
  let len = this._timers.length;
155
155
  while (i < len) {
@@ -166,7 +166,7 @@ export class Time {
166
166
  /**
167
167
  * Updates the advanced timing values.
168
168
  */
169
- public updateAdvancedTiming() {
169
+ public updateAdvancedTiming(): void {
170
170
  // count the number of time.update calls
171
171
  this._frameCount += 1;
172
172
  this._elapsedAccumulator += this.elapsed;
@@ -192,7 +192,7 @@ export class Time {
192
192
  /**
193
193
  * Handles game pause event.
194
194
  */
195
- public gamePaused() {
195
+ public gamePaused(): void {
196
196
  this._pauseStarted = Date.now();
197
197
  this.events.pause();
198
198
  let i = this._timers.length;
@@ -205,7 +205,7 @@ export class Time {
205
205
  /**
206
206
  * Handles game resume event.
207
207
  */
208
- public gameResumed() {
208
+ public gameResumed(): void {
209
209
  this.time = Date.now();
210
210
  this.pauseDuration = this.time - this._pauseStarted;
211
211
  this.events.resume();
@@ -220,7 +220,7 @@ export class Time {
220
220
  * Gets the total elapsed time in seconds since the game started.
221
221
  * @returns {number} The total elapsed time in seconds.
222
222
  */
223
- public totalElapsedSeconds() {
223
+ public totalElapsedSeconds(): number {
224
224
  return (this.time - this._started) * 0.001;
225
225
  }
226
226
 
@@ -229,7 +229,7 @@ export class Time {
229
229
  * @param {number} since - The timestamp to calculate elapsed time from.
230
230
  * @returns {number} The elapsed time in milliseconds.
231
231
  */
232
- public elapsedSince(since: number) {
232
+ public elapsedSince(since: number): number {
233
233
  return this.time - since;
234
234
  }
235
235
 
@@ -238,14 +238,14 @@ export class Time {
238
238
  * @param {number} since - The timestamp to calculate elapsed time from.
239
239
  * @returns {number} The elapsed time in seconds.
240
240
  */
241
- public elapsedSecondsSince(since: number) {
241
+ public elapsedSecondsSince(since: number): number {
242
242
  return (this.time - since) * 0.001;
243
243
  }
244
244
 
245
245
  /**
246
246
  * Resets the time tracking values.
247
247
  */
248
- public reset() {
248
+ public reset(): void {
249
249
  this._started = this.time;
250
250
  this.removeAll();
251
251
  }
@@ -253,7 +253,7 @@ export class Time {
253
253
  /**
254
254
  * Destroys the Time manager and cleans up resources.
255
255
  */
256
- public destroy() {
256
+ public destroy(): void {
257
257
  this.reset();
258
258
  }
259
259
 
@@ -261,7 +261,7 @@ export class Time {
261
261
  * Gets the desired frames per second.
262
262
  * @returns {number} The desired frames per second.
263
263
  */
264
- public get desiredFps() {
264
+ public get desiredFps(): number {
265
265
  return this._desiredFps;
266
266
  }
267
267