@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.
- package/dist/index.js +56 -96
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +15 -14
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +10 -9
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +20 -20
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +11 -13
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +19 -8
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +38 -13
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +2 -2
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +24 -22
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +26 -26
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +2 -2
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +9 -7
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +12 -10
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +18 -33
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -4
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +10 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +20 -20
- package/src/phaser/core/animation_manager.ts +27 -24
- package/src/phaser/core/animation_parser.ts +2 -2
- package/src/phaser/core/array_set.ts +7 -7
- package/src/phaser/core/cache.ts +55 -51
- package/src/phaser/core/callback_context.test.ts +70 -0
- package/src/phaser/core/device_util.ts +13 -13
- package/src/phaser/core/dom.ts +26 -22
- package/src/phaser/core/factory.ts +6 -6
- package/src/phaser/core/game.ts +10 -10
- package/src/phaser/core/input.ts +37 -39
- package/src/phaser/core/input_handler.ts +90 -93
- package/src/phaser/core/input_mouse.ts +19 -19
- package/src/phaser/core/input_mspointer.ts +15 -15
- package/src/phaser/core/input_pointer.ts +37 -28
- package/src/phaser/core/input_touch.ts +17 -17
- package/src/phaser/core/loader.ts +52 -52
- package/src/phaser/core/loader_parser.ts +3 -3
- package/src/phaser/core/raf.ts +3 -3
- package/src/phaser/core/scale_manager.ts +86 -67
- package/src/phaser/core/scene.ts +7 -7
- package/src/phaser/core/scene_manager.ts +16 -16
- package/src/phaser/core/signal.ts +29 -19
- package/src/phaser/core/signal_binding.ts +4 -4
- package/src/phaser/core/sound.ts +17 -17
- package/src/phaser/core/sound_manager.ts +71 -72
- package/src/phaser/core/sound_sprite.ts +1 -1
- package/src/phaser/core/stage.ts +7 -7
- package/src/phaser/core/time.ts +16 -16
- package/src/phaser/core/timer.ts +36 -26
- package/src/phaser/core/tween.ts +23 -23
- package/src/phaser/core/tween_data.ts +41 -37
- package/src/phaser/core/tween_manager.ts +11 -11
- package/src/phaser/core/world.ts +1 -1
- package/src/phaser/display/bitmap_text.ts +13 -13
- package/src/phaser/display/button.ts +13 -13
- package/src/phaser/display/canvas/buffer.ts +3 -3
- package/src/phaser/display/canvas/graphics.ts +3 -3
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.ts +6 -6
- package/src/phaser/display/canvas/renderer.ts +6 -6
- package/src/phaser/display/canvas/tinter.ts +39 -8
- package/src/phaser/display/canvas/util.ts +15 -9
- package/src/phaser/display/display_object.ts +38 -38
- package/src/phaser/display/graphics.ts +30 -30
- package/src/phaser/display/graphics_data.ts +1 -1
- package/src/phaser/display/graphics_data_util.ts +1 -1
- package/src/phaser/display/group.ts +16 -16
- package/src/phaser/display/image.ts +30 -26
- package/src/phaser/display/sprite_util.ts +12 -4
- package/src/phaser/display/text.ts +55 -55
- package/src/phaser/display/webgl/abstract_filter.ts +1 -1
- package/src/phaser/display/webgl/base_texture.ts +22 -18
- package/src/phaser/display/webgl/blend_manager.ts +3 -3
- package/src/phaser/display/webgl/earcut.ts +3 -3
- package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
- package/src/phaser/display/webgl/filter_manager.ts +7 -7
- package/src/phaser/display/webgl/filter_texture.ts +3 -3
- package/src/phaser/display/webgl/graphics.ts +43 -41
- package/src/phaser/display/webgl/graphics_data.ts +2 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +6 -6
- package/src/phaser/display/webgl/renderer.ts +20 -25
- package/src/phaser/display/webgl/shader/normal.ts +3 -3
- package/src/phaser/display/webgl/shader_manager.ts +2 -2
- package/src/phaser/display/webgl/sprite_batch.ts +9 -9
- package/src/phaser/display/webgl/stencil_manager.ts +4 -4
- package/src/phaser/display/webgl/texture.ts +23 -42
- package/src/phaser/display/webgl/texture_util.ts +2 -2
- package/src/phaser/display/webgl/util.ts +11 -7
- package/src/phaser/geom/circle.ts +21 -21
- package/src/phaser/geom/ellipse.ts +7 -7
- package/src/phaser/geom/line.ts +29 -29
- package/src/phaser/geom/matrix.ts +13 -13
- package/src/phaser/geom/point.ts +36 -30
- package/src/phaser/geom/polygon.ts +6 -6
- package/src/phaser/geom/rectangle.ts +42 -42
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +13 -5
- package/src/phaser/geom/util/matrix.ts +3 -3
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +34 -17
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
|
@@ -59,7 +59,7 @@ export class SceneManager {
|
|
|
59
59
|
* Initialize the scene manager.
|
|
60
60
|
* This method is called when the game boots and sets up the initial state.
|
|
61
61
|
*/
|
|
62
|
-
public boot() {
|
|
62
|
+
public boot(): void {
|
|
63
63
|
if (this._pendingState !== null && typeof this._pendingState !== 'string') {
|
|
64
64
|
this.add('default', this._pendingState, true);
|
|
65
65
|
}
|
|
@@ -97,7 +97,7 @@ export class SceneManager {
|
|
|
97
97
|
* Remove a scene state from the manager.
|
|
98
98
|
* @param {string} key - The unique key for the state to remove.
|
|
99
99
|
*/
|
|
100
|
-
public remove(key: string) {
|
|
100
|
+
public remove(key: string): void {
|
|
101
101
|
if (this.current === key) {
|
|
102
102
|
this.onInitCallback = null;
|
|
103
103
|
this.onShutDownCallback = null;
|
|
@@ -117,7 +117,7 @@ export class SceneManager {
|
|
|
117
117
|
* @param {boolean} clearCache - Whether to clear the cache before starting.
|
|
118
118
|
* @param {...any} args - Additional arguments to pass to the state.
|
|
119
119
|
*/
|
|
120
|
-
public start(key: string, clearWorld = true, clearCache = false, ...args: unknown[]) {
|
|
120
|
+
public start(key: string, clearWorld = true, clearCache = false, ...args: unknown[]): void {
|
|
121
121
|
if (this.checkState(key)) {
|
|
122
122
|
// Place the state in the queue. It will be started the next time the game loop begins.
|
|
123
123
|
this._pendingState = key;
|
|
@@ -135,7 +135,7 @@ export class SceneManager {
|
|
|
135
135
|
* @param {boolean} clearCache - Whether to clear the cache before restarting.
|
|
136
136
|
* @param {...any} args - Additional arguments to pass to the state.
|
|
137
137
|
*/
|
|
138
|
-
public restart(clearWorld = true, clearCache = false, ...args: unknown[]) {
|
|
138
|
+
public restart(clearWorld = true, clearCache = false, ...args: unknown[]): void {
|
|
139
139
|
this._pendingState = this.current;
|
|
140
140
|
this._clearWorld = clearWorld;
|
|
141
141
|
this._clearCache = clearCache;
|
|
@@ -148,7 +148,7 @@ export class SceneManager {
|
|
|
148
148
|
* Pre-update the scene manager.
|
|
149
149
|
* This method is called before the game loop updates.
|
|
150
150
|
*/
|
|
151
|
-
public preUpdate() {
|
|
151
|
+
public preUpdate(): void {
|
|
152
152
|
if (this._pendingState && this.game.isBooted) {
|
|
153
153
|
// var previousStateKey = this.current;
|
|
154
154
|
// Already got a state running?
|
|
@@ -183,7 +183,7 @@ export class SceneManager {
|
|
|
183
183
|
* Clear the current scene state.
|
|
184
184
|
* This method is called when switching scenes to clean up the previous scene.
|
|
185
185
|
*/
|
|
186
|
-
public clearCurrentState() {
|
|
186
|
+
public clearCurrentState(): void {
|
|
187
187
|
if (this.current) {
|
|
188
188
|
if (this.onShutDownCallback) {
|
|
189
189
|
this.onShutDownCallback.call(this.callbackContext, this.game);
|
|
@@ -206,7 +206,7 @@ export class SceneManager {
|
|
|
206
206
|
* @param {string} key - The unique key for the state to check.
|
|
207
207
|
* @returns {boolean} True if the scene exists, false otherwise.
|
|
208
208
|
*/
|
|
209
|
-
public checkState(key: string) {
|
|
209
|
+
public checkState(key: string): boolean {
|
|
210
210
|
if (this.states[key]) {
|
|
211
211
|
if (this.states[key].preload || this.states[key].create || this.states[key].update || this.states[key].render) {
|
|
212
212
|
return true;
|
|
@@ -220,7 +220,7 @@ export class SceneManager {
|
|
|
220
220
|
* Link a scene state to the manager.
|
|
221
221
|
* @param {string} key - The unique key for the state to link.
|
|
222
222
|
*/
|
|
223
|
-
public link(key: string) {
|
|
223
|
+
public link(key: string): void {
|
|
224
224
|
this.states[key].game = this.game;
|
|
225
225
|
this.states[key].key = key;
|
|
226
226
|
}
|
|
@@ -229,7 +229,7 @@ export class SceneManager {
|
|
|
229
229
|
* Unlink a scene state from the manager.
|
|
230
230
|
* @param {string} key - The unique key for the state to unlink.
|
|
231
231
|
*/
|
|
232
|
-
public unlink(key: string) {
|
|
232
|
+
public unlink(key: string): void {
|
|
233
233
|
if (this.states[key]) {
|
|
234
234
|
this.states[key].game = null;
|
|
235
235
|
}
|
|
@@ -239,7 +239,7 @@ export class SceneManager {
|
|
|
239
239
|
* Set the current scene state.
|
|
240
240
|
* @param {string} key - The unique key for the state to set as current.
|
|
241
241
|
*/
|
|
242
|
-
public setCurrentState(key: string) {
|
|
242
|
+
public setCurrentState(key: string): void {
|
|
243
243
|
this.callbackContext = this.states[key];
|
|
244
244
|
this.link(key);
|
|
245
245
|
// Used when the state is set as being the current active state
|
|
@@ -272,7 +272,7 @@ export class SceneManager {
|
|
|
272
272
|
* Handle loading completion.
|
|
273
273
|
* This method is called when scene loading is complete.
|
|
274
274
|
*/
|
|
275
|
-
public loadComplete() {
|
|
275
|
+
public loadComplete(): void {
|
|
276
276
|
if (this._created === false && this.onCreateCallback) {
|
|
277
277
|
this._created = true;
|
|
278
278
|
this.onCreateCallback.call(this.callbackContext, this.game);
|
|
@@ -285,7 +285,7 @@ export class SceneManager {
|
|
|
285
285
|
* Update the scene manager.
|
|
286
286
|
* This method is called every frame while the game is running.
|
|
287
287
|
*/
|
|
288
|
-
public update() {
|
|
288
|
+
public update(): void {
|
|
289
289
|
if (this._created && this.onUpdateCallback) {
|
|
290
290
|
this.onUpdateCallback.call(this.callbackContext, this.game);
|
|
291
291
|
}
|
|
@@ -295,7 +295,7 @@ export class SceneManager {
|
|
|
295
295
|
* Pause the scene manager updates.
|
|
296
296
|
* This method is called when the game is paused.
|
|
297
297
|
*/
|
|
298
|
-
public pauseUpdate() {
|
|
298
|
+
public pauseUpdate(): void {
|
|
299
299
|
if (this._created && this.onPauseUpdateCallback) {
|
|
300
300
|
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
|
|
301
301
|
}
|
|
@@ -306,7 +306,7 @@ export class SceneManager {
|
|
|
306
306
|
* @param {number} width - The new width of the scene.
|
|
307
307
|
* @param {number} height - The new height of the scene.
|
|
308
308
|
*/
|
|
309
|
-
public resize(width: number, height: number) {
|
|
309
|
+
public resize(width: number, height: number): void {
|
|
310
310
|
if (this.onResizeCallback) {
|
|
311
311
|
this.onResizeCallback.call(this.callbackContext, width, height);
|
|
312
312
|
}
|
|
@@ -316,7 +316,7 @@ export class SceneManager {
|
|
|
316
316
|
* Destroy the scene manager.
|
|
317
317
|
* This method is called when the scene manager is about to be destroyed.
|
|
318
318
|
*/
|
|
319
|
-
public destroy() {
|
|
319
|
+
public destroy(): void {
|
|
320
320
|
this._clearWorld = true;
|
|
321
321
|
this._clearCache = true;
|
|
322
322
|
this.clearCurrentState();
|
|
@@ -335,7 +335,7 @@ export class SceneManager {
|
|
|
335
335
|
* Dummy function for callbacks.
|
|
336
336
|
* This is a placeholder function used when no callback is defined.
|
|
337
337
|
*/
|
|
338
|
-
public dummy() {
|
|
338
|
+
public dummy(): void {
|
|
339
339
|
// pass
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -19,7 +19,7 @@ export class Signal {
|
|
|
19
19
|
* @param {string} fnName - The name of the function this validation is for.
|
|
20
20
|
* @throws {Error} If the listener is not a function.
|
|
21
21
|
*/
|
|
22
|
-
public validateListener(listener: Function, fnName: string) {
|
|
22
|
+
public validateListener(listener: Function, fnName: string): void {
|
|
23
23
|
if (typeof listener !== 'function') {
|
|
24
24
|
throw new TypeError(
|
|
25
25
|
'Signal: listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)
|
|
@@ -43,7 +43,7 @@ export class Signal {
|
|
|
43
43
|
listenerContext: unknown | null = null,
|
|
44
44
|
priority = 0,
|
|
45
45
|
args: any = null
|
|
46
|
-
) {
|
|
46
|
+
): SignalBinding {
|
|
47
47
|
const prevIndex = this._indexOfListener(listener, listenerContext);
|
|
48
48
|
let binding;
|
|
49
49
|
const existing = prevIndex !== -1 && this._bindings ? this._bindings[prevIndex] : undefined;
|
|
@@ -70,7 +70,7 @@ export class Signal {
|
|
|
70
70
|
* Add a binding to the list of listeners.
|
|
71
71
|
* @param {SignalBinding} binding - The binding to add.
|
|
72
72
|
*/
|
|
73
|
-
public _addBinding(binding: SignalBinding) {
|
|
73
|
+
public _addBinding(binding: SignalBinding): void {
|
|
74
74
|
this._bindings ??= [];
|
|
75
75
|
// Simplified insertion sort
|
|
76
76
|
let n = this._bindings.length;
|
|
@@ -86,7 +86,7 @@ export class Signal {
|
|
|
86
86
|
* @param {object} context - The context of the listener.
|
|
87
87
|
* @returns {number} The index of the listener in the bindings array, or -1 if not found.
|
|
88
88
|
*/
|
|
89
|
-
public _indexOfListener(listener: Function, context: unknown = null) {
|
|
89
|
+
public _indexOfListener(listener: Function, context: unknown = null): number {
|
|
90
90
|
if (!this._bindings) {
|
|
91
91
|
return -1;
|
|
92
92
|
}
|
|
@@ -108,7 +108,7 @@ export class Signal {
|
|
|
108
108
|
* @param {object} context - The context of the listener.
|
|
109
109
|
* @returns {boolean} True if the listener is registered, false otherwise.
|
|
110
110
|
*/
|
|
111
|
-
public has(listener: Function, context: unknown = null) {
|
|
111
|
+
public has(listener: Function, context: unknown = null): boolean {
|
|
112
112
|
return this._indexOfListener(listener, context) !== -1;
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -120,7 +120,12 @@ export class Signal {
|
|
|
120
120
|
* @param {...any} args - Additional arguments to pass to the listener.
|
|
121
121
|
* @returns {SignalBinding} The binding for this listener.
|
|
122
122
|
*/
|
|
123
|
-
public add(
|
|
123
|
+
public add(
|
|
124
|
+
listener: Function,
|
|
125
|
+
listenerContext: unknown | null = null,
|
|
126
|
+
priority = 0,
|
|
127
|
+
...args: unknown[]
|
|
128
|
+
): SignalBinding {
|
|
124
129
|
this.validateListener(listener, 'add');
|
|
125
130
|
return this._registerListener(listener, false, listenerContext, priority, args);
|
|
126
131
|
}
|
|
@@ -133,7 +138,12 @@ export class Signal {
|
|
|
133
138
|
* @param {...any} args - Additional arguments to pass to the listener.
|
|
134
139
|
* @returns {SignalBinding} The binding for this listener.
|
|
135
140
|
*/
|
|
136
|
-
public addOnce(
|
|
141
|
+
public addOnce(
|
|
142
|
+
listener: Function,
|
|
143
|
+
listenerContext: unknown | null = null,
|
|
144
|
+
priority = 0,
|
|
145
|
+
...args: unknown[]
|
|
146
|
+
): SignalBinding {
|
|
137
147
|
this.validateListener(listener, 'addOnce');
|
|
138
148
|
return this._registerListener(listener, true, listenerContext, priority, args);
|
|
139
149
|
}
|
|
@@ -144,7 +154,7 @@ export class Signal {
|
|
|
144
154
|
* @param {object} context - The context of the listener.
|
|
145
155
|
* @returns {Function} The removed listener function.
|
|
146
156
|
*/
|
|
147
|
-
public remove(listener: Function, context: unknown = null) {
|
|
157
|
+
public remove(listener: Function, context: unknown = null): Function {
|
|
148
158
|
this.validateListener(listener, 'remove');
|
|
149
159
|
const i = this._indexOfListener(listener, context);
|
|
150
160
|
if (i !== -1 && this._bindings) {
|
|
@@ -159,7 +169,7 @@ export class Signal {
|
|
|
159
169
|
* Remove all listeners from the signal, or only those in a specific context.
|
|
160
170
|
* @param {object} context - The context to filter listeners by, or null to remove all.
|
|
161
171
|
*/
|
|
162
|
-
public removeAll(context: unknown = null) {
|
|
172
|
+
public removeAll(context: unknown = null): void {
|
|
163
173
|
if (!this._bindings) {
|
|
164
174
|
return;
|
|
165
175
|
}
|
|
@@ -184,7 +194,7 @@ export class Signal {
|
|
|
184
194
|
* Get the number of listeners registered with the signal.
|
|
185
195
|
* @returns {number} The number of registered listeners.
|
|
186
196
|
*/
|
|
187
|
-
public getNumListeners() {
|
|
197
|
+
public getNumListeners(): number {
|
|
188
198
|
return this._bindings ? this._bindings.length : 0;
|
|
189
199
|
}
|
|
190
200
|
|
|
@@ -192,7 +202,7 @@ export class Signal {
|
|
|
192
202
|
* Stop the signal from propagating to other listeners.
|
|
193
203
|
* This method prevents any remaining listeners from being called.
|
|
194
204
|
*/
|
|
195
|
-
public halt() {
|
|
205
|
+
public halt(): void {
|
|
196
206
|
this._shouldPropagate = false;
|
|
197
207
|
}
|
|
198
208
|
|
|
@@ -200,7 +210,7 @@ export class Signal {
|
|
|
200
210
|
* Dispatch the signal to all registered listeners.
|
|
201
211
|
* @param {...any} args - Arguments to pass to the listeners.
|
|
202
212
|
*/
|
|
203
|
-
public dispatch(...args: unknown[]) {
|
|
213
|
+
public dispatch(...args: unknown[]): void {
|
|
204
214
|
if (!this.active || !this._bindings) {
|
|
205
215
|
return;
|
|
206
216
|
}
|
|
@@ -228,7 +238,7 @@ export class Signal {
|
|
|
228
238
|
* Clear any previously memorized arguments.
|
|
229
239
|
* This removes the stored arguments from a previous dispatch.
|
|
230
240
|
*/
|
|
231
|
-
public forget() {
|
|
241
|
+
public forget(): void {
|
|
232
242
|
if (this._prevParams) {
|
|
233
243
|
this._prevParams = null;
|
|
234
244
|
}
|
|
@@ -238,7 +248,7 @@ export class Signal {
|
|
|
238
248
|
* Dispose of the signal and clean up all resources.
|
|
239
249
|
* This method removes all listeners and clears internal state.
|
|
240
250
|
*/
|
|
241
|
-
public dispose() {
|
|
251
|
+
public dispose(): void {
|
|
242
252
|
this.removeAll();
|
|
243
253
|
this.forget();
|
|
244
254
|
this._bindings = null;
|
|
@@ -248,7 +258,7 @@ export class Signal {
|
|
|
248
258
|
* Get a string representation of the signal.
|
|
249
259
|
* @returns {string} A string representation of the signal.
|
|
250
260
|
*/
|
|
251
|
-
public toString() {
|
|
261
|
+
public toString(): string {
|
|
252
262
|
return `[Signal active:${this.active} numListeners:${this.getNumListeners()}]`;
|
|
253
263
|
}
|
|
254
264
|
|
|
@@ -258,7 +268,7 @@ export class Signal {
|
|
|
258
268
|
*/
|
|
259
269
|
public get boundDispatch() {
|
|
260
270
|
const _this = this;
|
|
261
|
-
this._boundDispatch ??= (...rest: unknown[]) => {
|
|
271
|
+
this._boundDispatch ??= (...rest: unknown[]): void => {
|
|
262
272
|
_this.dispatch(...rest);
|
|
263
273
|
};
|
|
264
274
|
return this._boundDispatch;
|
|
@@ -268,9 +278,9 @@ export class Signal {
|
|
|
268
278
|
* Promisify the Signal.
|
|
269
279
|
* @returns {Promise<any>} The resolved result.
|
|
270
280
|
*/
|
|
271
|
-
public toPromise() {
|
|
272
|
-
return new Promise((resolve) => {
|
|
273
|
-
this.addOnce((...args: unknown[]) => {
|
|
281
|
+
public toPromise(): Promise<unknown> {
|
|
282
|
+
return new Promise((resolve): void => {
|
|
283
|
+
this.addOnce((...args: unknown[]): void => {
|
|
274
284
|
resolve(args.length <= 1 ? args[0] : args);
|
|
275
285
|
}, this);
|
|
276
286
|
});
|
|
@@ -72,7 +72,7 @@ export class SignalBinding {
|
|
|
72
72
|
* TBD.
|
|
73
73
|
* @returns {boolean} TBD.
|
|
74
74
|
*/
|
|
75
|
-
public isBound() {
|
|
75
|
+
public isBound(): boolean {
|
|
76
76
|
return Boolean(this._signal) && Boolean(this._listener);
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -80,7 +80,7 @@ export class SignalBinding {
|
|
|
80
80
|
* TBD.
|
|
81
81
|
* @returns {boolean} TBD.
|
|
82
82
|
*/
|
|
83
|
-
public isOnce() {
|
|
83
|
+
public isOnce(): boolean {
|
|
84
84
|
return this._isOnce;
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -103,7 +103,7 @@ export class SignalBinding {
|
|
|
103
103
|
/**
|
|
104
104
|
* TBD.
|
|
105
105
|
*/
|
|
106
|
-
public _destroy() {
|
|
106
|
+
public _destroy(): void {
|
|
107
107
|
delete this._signal;
|
|
108
108
|
delete this._listener;
|
|
109
109
|
delete this.context;
|
|
@@ -113,7 +113,7 @@ export class SignalBinding {
|
|
|
113
113
|
* TBD.
|
|
114
114
|
* @returns {string} TBD.
|
|
115
115
|
*/
|
|
116
|
-
public toString() {
|
|
116
|
+
public toString(): string {
|
|
117
117
|
return `[SignalBinding isOnce:${this._isOnce}, isBound:${this.isBound()}, active:${this.active}]`;
|
|
118
118
|
}
|
|
119
119
|
}
|
package/src/phaser/core/sound.ts
CHANGED
|
@@ -122,7 +122,7 @@ export class Sound {
|
|
|
122
122
|
* Callback when a sound has been unlocked.
|
|
123
123
|
* @param {string} key - The key of the sound that was unlocked.
|
|
124
124
|
*/
|
|
125
|
-
public soundHasUnlocked(key: string) {
|
|
125
|
+
public soundHasUnlocked(key: string): void {
|
|
126
126
|
if (key === this.key) {
|
|
127
127
|
this._sound = this.game.cache.getSoundData(this.key);
|
|
128
128
|
this.totalDuration = (this._sound as any).duration;
|
|
@@ -137,7 +137,7 @@ export class Sound {
|
|
|
137
137
|
* @param {number} volume - The volume level (0.0 to 1.0) of the marker.
|
|
138
138
|
* @param {boolean} loop - Whether the marker should loop.
|
|
139
139
|
*/
|
|
140
|
-
public addMarker(name: string, start: number, duration = 1, volume = 1, loop = false) {
|
|
140
|
+
public addMarker(name: string, start: number, duration = 1, volume = 1, loop = false): void {
|
|
141
141
|
this.markers[name] = {
|
|
142
142
|
name,
|
|
143
143
|
start,
|
|
@@ -153,14 +153,14 @@ export class Sound {
|
|
|
153
153
|
* Removes a marker from the sound.
|
|
154
154
|
* @param {string} name - The name of the marker to remove.
|
|
155
155
|
*/
|
|
156
|
-
public removeMarker(name: string) {
|
|
156
|
+
public removeMarker(name: string): void {
|
|
157
157
|
delete this.markers[name];
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* Handler for when the sound ends.
|
|
162
162
|
*/
|
|
163
|
-
public onEndedHandler() {
|
|
163
|
+
public onEndedHandler(): void {
|
|
164
164
|
this._sound.onended = null;
|
|
165
165
|
this.isPlaying = false;
|
|
166
166
|
this.currentTime = this.durationMS;
|
|
@@ -194,7 +194,7 @@ export class Sound {
|
|
|
194
194
|
/**
|
|
195
195
|
* Updates the sound state.
|
|
196
196
|
*/
|
|
197
|
-
public update() {
|
|
197
|
+
public update(): void {
|
|
198
198
|
if (!this.game.cache.checkSoundKey(this.key)) {
|
|
199
199
|
this.destroy();
|
|
200
200
|
return;
|
|
@@ -233,7 +233,7 @@ export class Sound {
|
|
|
233
233
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
234
234
|
* @returns {Sound} This Sound instance for chaining.
|
|
235
235
|
*/
|
|
236
|
-
public loopFull(volume: number) {
|
|
236
|
+
public loopFull(volume: number): this {
|
|
237
237
|
return this.play(null, 0, volume, true);
|
|
238
238
|
}
|
|
239
239
|
|
|
@@ -246,7 +246,7 @@ export class Sound {
|
|
|
246
246
|
* @param {boolean} forceRestart - Whether to force restarting the sound even if it's already playing.
|
|
247
247
|
* @returns {Sound} This Sound instance for chaining.
|
|
248
248
|
*/
|
|
249
|
-
public play(marker: any = '', position: any = 0, volume: any = 1, loop: any = false, forceRestart = true) {
|
|
249
|
+
public play(marker: any = '', position: any = 0, volume: any = 1, loop: any = false, forceRestart = true): this {
|
|
250
250
|
if (marker === undefined || marker === false || marker === null) {
|
|
251
251
|
marker = '';
|
|
252
252
|
}
|
|
@@ -365,14 +365,14 @@ export class Sound {
|
|
|
365
365
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
366
366
|
* @param {boolean} loop - Whether the sound should loop.
|
|
367
367
|
*/
|
|
368
|
-
public restart(marker = '', position = 0, volume = 1, loop = false) {
|
|
368
|
+
public restart(marker = '', position = 0, volume = 1, loop = false): void {
|
|
369
369
|
this.play(marker, position, volume, loop, true);
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
/**
|
|
373
373
|
* Pauses the sound.
|
|
374
374
|
*/
|
|
375
|
-
public pause() {
|
|
375
|
+
public pause(): void {
|
|
376
376
|
if (this.isPlaying && this._sound) {
|
|
377
377
|
this.paused = true;
|
|
378
378
|
this.pausedPosition = this.currentTime;
|
|
@@ -386,7 +386,7 @@ export class Sound {
|
|
|
386
386
|
/**
|
|
387
387
|
* Resumes the sound.
|
|
388
388
|
*/
|
|
389
|
-
public resume() {
|
|
389
|
+
public resume(): void {
|
|
390
390
|
if (this.paused && this._sound) {
|
|
391
391
|
const p = Math.max(0, this.position + this.pausedPosition / 1000);
|
|
392
392
|
this._sound = this.context!.createBufferSource();
|
|
@@ -418,7 +418,7 @@ export class Sound {
|
|
|
418
418
|
/**
|
|
419
419
|
* Stops the sound.
|
|
420
420
|
*/
|
|
421
|
-
public stop() {
|
|
421
|
+
public stop(): void {
|
|
422
422
|
if (this.isPlaying && this._sound) {
|
|
423
423
|
if (this._sound.stop === undefined) {
|
|
424
424
|
(this._sound as any).noteOff(0);
|
|
@@ -452,7 +452,7 @@ export class Sound {
|
|
|
452
452
|
* @param {boolean} loop - Whether the sound should loop.
|
|
453
453
|
* @param {string} marker - The name of the marker to fade in, or empty string to use current marker.
|
|
454
454
|
*/
|
|
455
|
-
public fadeIn(duration: number, loop = false, marker: string = this.currentMarker) {
|
|
455
|
+
public fadeIn(duration: number, loop = false, marker: string = this.currentMarker): void {
|
|
456
456
|
if (this.paused) {
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
@@ -464,7 +464,7 @@ export class Sound {
|
|
|
464
464
|
* Fades out the sound to silence.
|
|
465
465
|
* @param {number} duration - The fade-out duration (in milliseconds).
|
|
466
466
|
*/
|
|
467
|
-
public fadeOut(duration: number) {
|
|
467
|
+
public fadeOut(duration: number): void {
|
|
468
468
|
this.fadeTo(duration, 0);
|
|
469
469
|
}
|
|
470
470
|
|
|
@@ -473,7 +473,7 @@ export class Sound {
|
|
|
473
473
|
* @param {number} duration - The fade duration (in milliseconds).
|
|
474
474
|
* @param {number} volume - The target volume level (0.0 to 1.0).
|
|
475
475
|
*/
|
|
476
|
-
public fadeTo(duration = 100, volume = 0) {
|
|
476
|
+
public fadeTo(duration = 100, volume = 0): void {
|
|
477
477
|
if (!this.isPlaying || this.paused || volume === this.volume) {
|
|
478
478
|
return;
|
|
479
479
|
}
|
|
@@ -484,7 +484,7 @@ export class Sound {
|
|
|
484
484
|
/**
|
|
485
485
|
* Callback when fade completes.
|
|
486
486
|
*/
|
|
487
|
-
public fadeComplete() {
|
|
487
|
+
public fadeComplete(): void {
|
|
488
488
|
this.onFadeComplete.dispatch(this, this.volume);
|
|
489
489
|
if (this.volume === 0) {
|
|
490
490
|
this.stop();
|
|
@@ -495,7 +495,7 @@ export class Sound {
|
|
|
495
495
|
* Destroys the sound and cleans up resources.
|
|
496
496
|
* @param {boolean} remove - Whether to remove the sound from the SoundManager.
|
|
497
497
|
*/
|
|
498
|
-
public destroy(remove = true) {
|
|
498
|
+
public destroy(remove = true): void {
|
|
499
499
|
this._markedToDelete = true;
|
|
500
500
|
this._removeFromSoundManager = remove;
|
|
501
501
|
this.stop();
|
|
@@ -548,7 +548,7 @@ export class Sound {
|
|
|
548
548
|
* Gets the volume of the sound.
|
|
549
549
|
* @returns {number} The volume level (0.0 to 1.0).
|
|
550
550
|
*/
|
|
551
|
-
public get volume() {
|
|
551
|
+
public get volume(): number {
|
|
552
552
|
return this._volume;
|
|
553
553
|
}
|
|
554
554
|
|