@vpmedia/phaser 1.103.0 → 1.105.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 +997 -403
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -11
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +20 -10
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +3 -3
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +68 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts +10 -10
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +6 -5
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +49 -158
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +8 -7
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts +27 -48
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +11 -58
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts +4 -14
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +50 -3
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +66 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +64 -20
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +26 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +18 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +53 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +19 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +56 -28
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +2 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +77 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +25 -9
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +9 -8
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +2 -2
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +58 -10
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +28 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +10 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +7 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +32 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +30 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -12
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +38 -14
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +30 -5
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +8 -4
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +35 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +24 -8
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +6 -2
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- 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 +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +18 -5
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -3
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +9 -9
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +82 -23
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +42 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +11 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +24 -9
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +36 -13
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +86 -66
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +8 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +5 -2
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +10 -10
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +17 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +7 -2
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +11 -10
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +11 -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 +12 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +25 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +35 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +6 -6
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +11 -10
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +6 -5
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +14 -14
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +13 -12
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts +19 -19
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +6 -6
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +20 -20
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +9 -7
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +19 -19
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +2 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +17 -15
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts +51 -142
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/phaser/core/animation.ts +41 -18
- package/src/phaser/core/animation_manager.ts +21 -12
- package/src/phaser/core/animation_parser.ts +11 -3
- package/src/phaser/core/array_set.ts +8 -8
- package/src/phaser/core/cache.ts +75 -60
- package/src/phaser/core/device.ts +23 -1
- package/src/phaser/core/device_util.ts +10 -10
- package/src/phaser/core/dom.ts +5 -5
- package/src/phaser/core/event_manager.ts +52 -177
- package/src/phaser/core/factory.ts +25 -17
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -74
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +40 -11
- package/src/phaser/core/input.ts +68 -17
- package/src/phaser/core/input_handler.ts +81 -45
- package/src/phaser/core/input_mouse.ts +42 -13
- package/src/phaser/core/input_mspointer.ts +24 -9
- package/src/phaser/core/input_pointer.ts +55 -12
- package/src/phaser/core/input_touch.ts +26 -9
- package/src/phaser/core/loader.ts +97 -42
- package/src/phaser/core/loader_parser.ts +6 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -27
- package/src/phaser/core/scene.ts +3 -2
- package/src/phaser/core/scene_manager.ts +26 -11
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +72 -26
- package/src/phaser/core/sound_manager.ts +31 -13
- package/src/phaser/core/sound_sprite.ts +10 -5
- package/src/phaser/core/stage.ts +8 -4
- package/src/phaser/core/time.ts +33 -7
- package/src/phaser/core/timer.ts +40 -14
- package/src/phaser/core/timer_event.ts +23 -14
- package/src/phaser/core/tween.ts +43 -23
- package/src/phaser/core/tween_data.ts +31 -7
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -7
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -18
- package/src/phaser/display/button.ts +24 -23
- package/src/phaser/display/canvas/buffer.ts +6 -3
- package/src/phaser/display/canvas/graphics.ts +3 -4
- package/src/phaser/display/canvas/masker.ts +2 -3
- package/src/phaser/display/canvas/pool.ts +3 -4
- package/src/phaser/display/canvas/renderer.ts +19 -7
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +9 -9
- package/src/phaser/display/display_object.ts +120 -61
- package/src/phaser/display/graphics.ts +56 -25
- package/src/phaser/display/graphics_data.ts +11 -2
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -14
- package/src/phaser/display/image.ts +37 -19
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +5 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -2
- package/src/phaser/display/webgl/base_texture.ts +14 -3
- package/src/phaser/display/webgl/blend_manager.ts +5 -3
- package/src/phaser/display/webgl/earcut.ts +27 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -4
- package/src/phaser/display/webgl/filter_manager.ts +5 -2
- package/src/phaser/display/webgl/filter_texture.ts +7 -3
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -2
- package/src/phaser/display/webgl/renderer.ts +24 -7
- package/src/phaser/display/webgl/shader/complex.ts +7 -2
- package/src/phaser/display/webgl/shader/fast.ts +8 -2
- package/src/phaser/display/webgl/shader/normal.ts +12 -2
- package/src/phaser/display/webgl/shader/primitive.ts +7 -2
- package/src/phaser/display/webgl/shader/strip.ts +7 -2
- package/src/phaser/display/webgl/shader_manager.ts +13 -3
- package/src/phaser/display/webgl/sprite_batch.ts +20 -4
- package/src/phaser/display/webgl/stencil_manager.ts +8 -5
- package/src/phaser/display/webgl/texture.ts +35 -4
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +6 -6
- package/src/phaser/geom/circle.ts +10 -10
- package/src/phaser/geom/ellipse.ts +6 -6
- package/src/phaser/geom/line.ts +14 -14
- package/src/phaser/geom/matrix.ts +12 -12
- package/src/phaser/geom/point.ts +19 -19
- package/src/phaser/geom/polygon.ts +5 -5
- package/src/phaser/geom/rectangle.ts +21 -21
- 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 +5 -5
- package/src/phaser/geom/util/matrix.ts +1 -1
- 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 +15 -15
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.ts +65 -151
package/src/phaser/core/sound.ts
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Signal } from './signal.js';
|
|
3
2
|
|
|
4
3
|
export class Sound {
|
|
4
|
+
_paused!: any;
|
|
5
|
+
game!: import('./game.js').Game;
|
|
6
|
+
name!: string;
|
|
7
|
+
key!: string;
|
|
8
|
+
loop!: boolean;
|
|
9
|
+
markers!: any;
|
|
10
|
+
context!: AudioContext;
|
|
11
|
+
autoplay!: boolean;
|
|
12
|
+
totalDuration!: number;
|
|
13
|
+
startTime!: number;
|
|
14
|
+
currentTime!: number;
|
|
15
|
+
duration!: number;
|
|
16
|
+
durationMS!: number;
|
|
17
|
+
position!: number;
|
|
18
|
+
stopTime!: number;
|
|
19
|
+
paused!: boolean;
|
|
20
|
+
pausedPosition!: number;
|
|
21
|
+
pausedTime!: number;
|
|
22
|
+
isPlaying!: boolean;
|
|
23
|
+
currentMarker!: string;
|
|
24
|
+
fadeTween!: import('./tween.js').Tween | null;
|
|
25
|
+
pendingPlayback!: boolean;
|
|
26
|
+
override!: boolean;
|
|
27
|
+
allowMultiple!: boolean;
|
|
28
|
+
externalNode!: AudioNode | null;
|
|
29
|
+
masterGainNode!: GainNode | null;
|
|
30
|
+
gainNode!: GainNode | null;
|
|
31
|
+
_sound!: AudioBufferSourceNode | null;
|
|
32
|
+
_markedToDelete!: boolean;
|
|
33
|
+
_removeFromSoundManager!: boolean;
|
|
34
|
+
onPlay!: Signal;
|
|
35
|
+
onPause!: Signal;
|
|
36
|
+
onResume!: Signal;
|
|
37
|
+
onLoop!: Signal;
|
|
38
|
+
onStop!: Signal;
|
|
39
|
+
onMute!: Signal;
|
|
40
|
+
onMarkerComplete!: Signal;
|
|
41
|
+
onFadeComplete!: Signal;
|
|
42
|
+
_volume!: number;
|
|
43
|
+
_buffer!: AudioBuffer | null;
|
|
44
|
+
_muted!: boolean;
|
|
45
|
+
_tempMarker!: string;
|
|
46
|
+
_tempPosition!: number;
|
|
47
|
+
_tempVolume!: number;
|
|
48
|
+
_tempPause!: number;
|
|
49
|
+
_muteVolume!: number;
|
|
50
|
+
_tempLoop!: boolean;
|
|
5
51
|
/**
|
|
6
52
|
* Creates a new Sound instance.
|
|
7
53
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
@@ -10,7 +56,7 @@ export class Sound {
|
|
|
10
56
|
* @param {boolean} loop - Whether the sound should loop.
|
|
11
57
|
* @param {boolean} connect - Whether to connect to the master gain node.
|
|
12
58
|
*/
|
|
13
|
-
constructor(game, key, volume = 1, loop = false, connect = null) {
|
|
59
|
+
constructor(game: import('./game.js').Game, key: string, volume: number = 1, loop: boolean = false, connect: boolean = null) {
|
|
14
60
|
// TODO
|
|
15
61
|
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
|
|
16
62
|
if (!connect) {
|
|
@@ -52,7 +98,7 @@ export class Sound {
|
|
|
52
98
|
this.context = this.game.sound.context;
|
|
53
99
|
this.masterGainNode = this.game.sound.masterGain;
|
|
54
100
|
if (this.context.createGain === undefined) {
|
|
55
|
-
this.gainNode = this.context.createGainNode();
|
|
101
|
+
this.gainNode = (this.context as any).createGainNode();
|
|
56
102
|
} else {
|
|
57
103
|
this.gainNode = this.context.createGain();
|
|
58
104
|
}
|
|
@@ -85,10 +131,10 @@ export class Sound {
|
|
|
85
131
|
* Callback when a sound has been unlocked.
|
|
86
132
|
* @param {string} key - The key of the sound that was unlocked.
|
|
87
133
|
*/
|
|
88
|
-
soundHasUnlocked(key) {
|
|
134
|
+
soundHasUnlocked(key: string) {
|
|
89
135
|
if (key === this.key) {
|
|
90
136
|
this._sound = this.game.cache.getSoundData(this.key);
|
|
91
|
-
this.totalDuration = this._sound.duration;
|
|
137
|
+
this.totalDuration = (this._sound as any).duration;
|
|
92
138
|
}
|
|
93
139
|
}
|
|
94
140
|
|
|
@@ -100,7 +146,7 @@ export class Sound {
|
|
|
100
146
|
* @param {number} volume - The volume level (0.0 to 1.0) of the marker.
|
|
101
147
|
* @param {boolean} loop - Whether the marker should loop.
|
|
102
148
|
*/
|
|
103
|
-
addMarker(name, start, duration = 1, volume = 1, loop = false) {
|
|
149
|
+
addMarker(name: string, start: number, duration: number = 1, volume: number = 1, loop: boolean = false) {
|
|
104
150
|
this.markers[name] = {
|
|
105
151
|
name,
|
|
106
152
|
start,
|
|
@@ -116,7 +162,7 @@ export class Sound {
|
|
|
116
162
|
* Removes a marker from the sound.
|
|
117
163
|
* @param {string} name - The name of the marker to remove.
|
|
118
164
|
*/
|
|
119
|
-
removeMarker(name) {
|
|
165
|
+
removeMarker(name: string) {
|
|
120
166
|
delete this.markers[name];
|
|
121
167
|
}
|
|
122
168
|
|
|
@@ -172,14 +218,14 @@ export class Sound {
|
|
|
172
218
|
this.currentTime = this.game.time.time - this.startTime;
|
|
173
219
|
if (this.currentTime >= this.durationMS) {
|
|
174
220
|
if (this.loop) {
|
|
175
|
-
//
|
|
221
|
+
// Won't work with markers, needs to reset the position
|
|
176
222
|
this.onLoop.dispatch(this);
|
|
177
223
|
// Gets reset by the play function
|
|
178
224
|
this.isPlaying = false;
|
|
179
225
|
if (this.currentMarker === '') {
|
|
180
226
|
this.currentTime = 0;
|
|
181
227
|
this.startTime = this.game.time.time;
|
|
182
|
-
this.isPlaying = true; //
|
|
228
|
+
this.isPlaying = true; // Play not called again in this case
|
|
183
229
|
} else {
|
|
184
230
|
this.onMarkerComplete.dispatch(this.currentMarker, this);
|
|
185
231
|
this.play(this.currentMarker, 0, this.volume, true, true);
|
|
@@ -196,7 +242,7 @@ export class Sound {
|
|
|
196
242
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
197
243
|
* @returns {Sound} This Sound instance for chaining.
|
|
198
244
|
*/
|
|
199
|
-
loopFull(volume) {
|
|
245
|
+
loopFull(volume: number) {
|
|
200
246
|
return this.play(null, 0, volume, true);
|
|
201
247
|
}
|
|
202
248
|
|
|
@@ -209,7 +255,7 @@ export class Sound {
|
|
|
209
255
|
* @param {boolean} forceRestart - Whether to force restarting the sound even if it's already playing.
|
|
210
256
|
* @returns {Sound} This Sound instance for chaining.
|
|
211
257
|
*/
|
|
212
|
-
play(marker, position, volume, loop, forceRestart = true) {
|
|
258
|
+
play(marker: any = '', position: any = 0, volume: any = 1, loop: any = false, forceRestart: boolean = true) {
|
|
213
259
|
if (marker === undefined || marker === false || marker === null) {
|
|
214
260
|
marker = '';
|
|
215
261
|
}
|
|
@@ -223,7 +269,7 @@ export class Sound {
|
|
|
223
269
|
}
|
|
224
270
|
if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || forceRestart)) {
|
|
225
271
|
if (this._sound.stop === undefined) {
|
|
226
|
-
this._sound.noteOff(0);
|
|
272
|
+
(this._sound as any).noteOff(0);
|
|
227
273
|
} else {
|
|
228
274
|
this._sound.stop(0);
|
|
229
275
|
}
|
|
@@ -236,7 +282,7 @@ export class Sound {
|
|
|
236
282
|
}
|
|
237
283
|
if (marker === '' && Object.keys(this.markers).length > 0) {
|
|
238
284
|
// If they didn't specify a marker but this is an audio sprite,
|
|
239
|
-
//
|
|
285
|
+
// We should never play the entire thing
|
|
240
286
|
return this;
|
|
241
287
|
}
|
|
242
288
|
if (marker !== '') {
|
|
@@ -248,10 +294,10 @@ export class Sound {
|
|
|
248
294
|
this.loop = this.markers[marker].loop;
|
|
249
295
|
this.duration = this.markers[marker].duration;
|
|
250
296
|
this.durationMS = this.markers[marker].durationMS;
|
|
251
|
-
if (
|
|
297
|
+
if (volume !== undefined) {
|
|
252
298
|
this.volume = volume;
|
|
253
299
|
}
|
|
254
|
-
if (
|
|
300
|
+
if (loop !== undefined) {
|
|
255
301
|
this.loop = loop;
|
|
256
302
|
}
|
|
257
303
|
this._tempMarker = marker;
|
|
@@ -268,7 +314,7 @@ export class Sound {
|
|
|
268
314
|
volume = this._volume;
|
|
269
315
|
}
|
|
270
316
|
if (loop === undefined) {
|
|
271
|
-
loop = this
|
|
317
|
+
({ loop } = this);
|
|
272
318
|
}
|
|
273
319
|
this.position = Math.max(0, position);
|
|
274
320
|
this.volume = volume;
|
|
@@ -303,7 +349,7 @@ export class Sound {
|
|
|
303
349
|
}
|
|
304
350
|
// Useful to cache this somewhere perhaps?
|
|
305
351
|
if (this._sound.start === undefined) {
|
|
306
|
-
this._sound.noteGrainOn(0, this.position, this.duration);
|
|
352
|
+
(this._sound as any).noteGrainOn(0, this.position, this.duration);
|
|
307
353
|
} else if (this.loop && marker === '') {
|
|
308
354
|
this._sound.start(0, 0);
|
|
309
355
|
} else {
|
|
@@ -330,7 +376,7 @@ export class Sound {
|
|
|
330
376
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
331
377
|
* @param {boolean} loop - Whether the sound should loop.
|
|
332
378
|
*/
|
|
333
|
-
restart(marker = '', position = 0, volume = 1, loop = false) {
|
|
379
|
+
restart(marker: string = '', position: number = 0, volume: number = 1, loop: boolean = false) {
|
|
334
380
|
this.play(marker, position, volume, loop, true);
|
|
335
381
|
}
|
|
336
382
|
|
|
@@ -342,7 +388,7 @@ export class Sound {
|
|
|
342
388
|
this.paused = true;
|
|
343
389
|
this.pausedPosition = this.currentTime;
|
|
344
390
|
this.pausedTime = this.game.time.time;
|
|
345
|
-
this._tempPause = this._sound.currentTime;
|
|
391
|
+
this._tempPause = (this._sound as any).currentTime;
|
|
346
392
|
this.onPause.dispatch(this);
|
|
347
393
|
this.stop();
|
|
348
394
|
}
|
|
@@ -369,7 +415,7 @@ export class Sound {
|
|
|
369
415
|
}
|
|
370
416
|
const duration = this.duration - this.pausedPosition / 1000;
|
|
371
417
|
if (this._sound.start === undefined) {
|
|
372
|
-
this._sound.noteGrainOn(0, p, duration);
|
|
418
|
+
(this._sound as any).noteGrainOn(0, p, duration);
|
|
373
419
|
} else {
|
|
374
420
|
this._sound.start(0, p, duration);
|
|
375
421
|
}
|
|
@@ -386,7 +432,7 @@ export class Sound {
|
|
|
386
432
|
stop() {
|
|
387
433
|
if (this.isPlaying && this._sound) {
|
|
388
434
|
if (this._sound.stop === undefined) {
|
|
389
|
-
this._sound.noteOff(0);
|
|
435
|
+
(this._sound as any).noteOff(0);
|
|
390
436
|
} else {
|
|
391
437
|
this._sound.stop(0);
|
|
392
438
|
}
|
|
@@ -417,7 +463,7 @@ export class Sound {
|
|
|
417
463
|
* @param {boolean} loop - Whether the sound should loop.
|
|
418
464
|
* @param {string} marker - The name of the marker to fade in, or empty string to use current marker.
|
|
419
465
|
*/
|
|
420
|
-
fadeIn(duration, loop = false, marker = this.currentMarker) {
|
|
466
|
+
fadeIn(duration: number, loop: boolean = false, marker: string = this.currentMarker) {
|
|
421
467
|
if (this.paused) {
|
|
422
468
|
return;
|
|
423
469
|
}
|
|
@@ -429,7 +475,7 @@ export class Sound {
|
|
|
429
475
|
* Fades out the sound to silence.
|
|
430
476
|
* @param {number} duration - The fade-out duration (in milliseconds).
|
|
431
477
|
*/
|
|
432
|
-
fadeOut(duration) {
|
|
478
|
+
fadeOut(duration: number) {
|
|
433
479
|
this.fadeTo(duration, 0);
|
|
434
480
|
}
|
|
435
481
|
|
|
@@ -438,7 +484,7 @@ export class Sound {
|
|
|
438
484
|
* @param {number} duration - The fade duration (in milliseconds).
|
|
439
485
|
* @param {number} volume - The target volume level (0.0 to 1.0).
|
|
440
486
|
*/
|
|
441
|
-
fadeTo(duration = 100, volume = 0) {
|
|
487
|
+
fadeTo(duration: number = 100, volume: number = 0) {
|
|
442
488
|
if (!this.isPlaying || this.paused || volume === this.volume) {
|
|
443
489
|
return;
|
|
444
490
|
}
|
|
@@ -460,7 +506,7 @@ export class Sound {
|
|
|
460
506
|
* Destroys the sound and cleans up resources.
|
|
461
507
|
* @param {boolean} remove - Whether to remove the sound from the SoundManager.
|
|
462
508
|
*/
|
|
463
|
-
destroy(remove = true) {
|
|
509
|
+
destroy(remove: boolean = true) {
|
|
464
510
|
this._markedToDelete = true;
|
|
465
511
|
this._removeFromSoundManager = remove;
|
|
466
512
|
this.stop();
|
|
@@ -529,4 +575,4 @@ export class Sound {
|
|
|
529
575
|
this._volume = value;
|
|
530
576
|
this.gainNode.gain.value = value;
|
|
531
577
|
}
|
|
532
|
-
}
|
|
578
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import {
|
|
3
2
|
addPageLifecycleCallback,
|
|
4
3
|
getPageLifecycleEventEmitter,
|
|
@@ -13,11 +12,30 @@ import { Sound } from './sound.js';
|
|
|
13
12
|
import { SoundSprite } from './sound_sprite.js';
|
|
14
13
|
|
|
15
14
|
export class SoundManager {
|
|
15
|
+
game!: any;
|
|
16
|
+
onChange!: any;
|
|
17
|
+
context!: any;
|
|
18
|
+
baseLatency!: any;
|
|
19
|
+
noAudio!: any;
|
|
20
|
+
type!: any;
|
|
21
|
+
connectToMaster!: any;
|
|
22
|
+
isLocked!: any;
|
|
23
|
+
_codeMuted!: any;
|
|
24
|
+
_muted!: any;
|
|
25
|
+
_unlockSource!: any;
|
|
26
|
+
_volume!: any;
|
|
27
|
+
_sounds!: any;
|
|
28
|
+
_watchList!: any;
|
|
29
|
+
_watching!: any;
|
|
30
|
+
_watchCallback!: any;
|
|
31
|
+
_watchContext!: any;
|
|
32
|
+
masterGain!: any;
|
|
33
|
+
_muteVolume!: any;
|
|
16
34
|
/**
|
|
17
35
|
* Creates a new SoundManager instance.
|
|
18
36
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
19
37
|
*/
|
|
20
|
-
constructor(game) {
|
|
38
|
+
constructor(game: import('./game.js').Game) {
|
|
21
39
|
this.game = game;
|
|
22
40
|
this.onChange = new Signal();
|
|
23
41
|
/** @type {AudioContext} */
|
|
@@ -64,10 +82,10 @@ export class SoundManager {
|
|
|
64
82
|
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
65
83
|
this.game.logger.exception('SoundManager', typedError);
|
|
66
84
|
}
|
|
67
|
-
} else if (window.webkitAudioContext) {
|
|
85
|
+
} else if ((window as any).webkitAudioContext) {
|
|
68
86
|
try {
|
|
69
87
|
this.game.logger.info('initWebkitAudioContext');
|
|
70
|
-
this.context = new window.webkitAudioContext();
|
|
88
|
+
this.context = new (window as any).webkitAudioContext();
|
|
71
89
|
this.type = AUDIO_WEBKIT;
|
|
72
90
|
} catch (error) {
|
|
73
91
|
this.context = null;
|
|
@@ -165,7 +183,7 @@ export class SoundManager {
|
|
|
165
183
|
* Handles unlock events to resume audio context.
|
|
166
184
|
* @param {Event} event - The DOM event that triggered the unlock.
|
|
167
185
|
*/
|
|
168
|
-
onUnlockEvent = (event) => {
|
|
186
|
+
onUnlockEvent = (event: Event) => {
|
|
169
187
|
const initialState = this.context.state;
|
|
170
188
|
if (initialState !== 'suspended' && initialState !== 'interrupted') {
|
|
171
189
|
this.game.logger.info('onUnlockResumeDenied', {
|
|
@@ -251,7 +269,7 @@ export class SoundManager {
|
|
|
251
269
|
* Decodes an audio file for playback.
|
|
252
270
|
* @param {string} key - The key of the sound to decode.
|
|
253
271
|
*/
|
|
254
|
-
decode(key) {
|
|
272
|
+
decode(key: string) {
|
|
255
273
|
const soundData = this.game.cache.getSoundData(key);
|
|
256
274
|
if (!soundData) {
|
|
257
275
|
return;
|
|
@@ -284,7 +302,7 @@ export class SoundManager {
|
|
|
284
302
|
* @param {Function} callback - The callback function to call when all files are decoded.
|
|
285
303
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
286
304
|
*/
|
|
287
|
-
setDecodedCallback(files, callback, callbackContext) {
|
|
305
|
+
setDecodedCallback(files: any, callback: Function, callbackContext: any) {
|
|
288
306
|
if (typeof files === 'string') {
|
|
289
307
|
files = [files];
|
|
290
308
|
}
|
|
@@ -343,7 +361,7 @@ export class SoundManager {
|
|
|
343
361
|
* @param {boolean} connect - Whether to connect to the master gain node.
|
|
344
362
|
* @returns {Sound} The created Sound object.
|
|
345
363
|
*/
|
|
346
|
-
add(key, volume = 1, loop = false, connect = this.connectToMaster) {
|
|
364
|
+
add(key: string, volume: number = 1, loop: boolean = false, connect: boolean = this.connectToMaster) {
|
|
347
365
|
const sound = new Sound(this.game, key, volume, loop, connect);
|
|
348
366
|
this._sounds.push(sound);
|
|
349
367
|
return sound;
|
|
@@ -354,7 +372,7 @@ export class SoundManager {
|
|
|
354
372
|
* @param {string} key - The key of the sound sprite to add.
|
|
355
373
|
* @returns {SoundSprite} The created SoundSprite object.
|
|
356
374
|
*/
|
|
357
|
-
addSprite(key) {
|
|
375
|
+
addSprite(key: string) {
|
|
358
376
|
return new SoundSprite(this.game, key);
|
|
359
377
|
}
|
|
360
378
|
|
|
@@ -363,7 +381,7 @@ export class SoundManager {
|
|
|
363
381
|
* @param {Sound | null | undefined} sound - The sound object to remove.
|
|
364
382
|
* @returns {boolean} True if the sound was removed, false otherwise.
|
|
365
383
|
*/
|
|
366
|
-
remove(sound) {
|
|
384
|
+
remove(sound: Sound | null | undefined) {
|
|
367
385
|
let i = this._sounds.length;
|
|
368
386
|
while (i) {
|
|
369
387
|
i -= 1;
|
|
@@ -381,7 +399,7 @@ export class SoundManager {
|
|
|
381
399
|
* @param {string} key - The key of sounds to remove.
|
|
382
400
|
* @returns {number} The number of sounds removed.
|
|
383
401
|
*/
|
|
384
|
-
removeByKey(key) {
|
|
402
|
+
removeByKey(key: string) {
|
|
385
403
|
let i = this._sounds.length;
|
|
386
404
|
let removed = 0;
|
|
387
405
|
while (i) {
|
|
@@ -402,7 +420,7 @@ export class SoundManager {
|
|
|
402
420
|
* @param {boolean} loop - Whether the sound should loop.
|
|
403
421
|
* @returns {Sound} The created Sound object, or null if audio is disabled.
|
|
404
422
|
*/
|
|
405
|
-
play(key, volume = 1, loop = false) {
|
|
423
|
+
play(key: string, volume: number = 1, loop: boolean = false) {
|
|
406
424
|
if (this.noAudio) {
|
|
407
425
|
return null;
|
|
408
426
|
}
|
|
@@ -508,4 +526,4 @@ export class SoundManager {
|
|
|
508
526
|
}
|
|
509
527
|
}
|
|
510
528
|
}
|
|
511
|
-
}
|
|
529
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
export class SoundSprite {
|
|
2
|
+
game!: any;
|
|
3
|
+
key!: any;
|
|
4
|
+
config!: any;
|
|
5
|
+
autoplayKey!: any;
|
|
6
|
+
autoplay!: any;
|
|
7
|
+
sounds!: any;
|
|
3
8
|
/**
|
|
4
9
|
* TBD.
|
|
5
10
|
* @param {import('./game.js').Game} game - TBD.
|
|
6
11
|
* @param {string} key - TBD.
|
|
7
12
|
*/
|
|
8
|
-
constructor(game, key) {
|
|
13
|
+
constructor(game: import('./game.js').Game, key: string) {
|
|
9
14
|
this.game = game;
|
|
10
15
|
this.key = key;
|
|
11
16
|
this.config = this.game.cache.getJSON(`${key}-audioatlas`);
|
|
@@ -32,7 +37,7 @@ export class SoundSprite {
|
|
|
32
37
|
* @param {number} volume - TBD.
|
|
33
38
|
* @returns {import('./sound.js').Sound} TBD.
|
|
34
39
|
*/
|
|
35
|
-
play(marker, volume = 1) {
|
|
40
|
+
play(marker: string, volume: number = 1) {
|
|
36
41
|
return this.sounds[marker].play(marker, null, volume);
|
|
37
42
|
}
|
|
38
43
|
|
|
@@ -40,7 +45,7 @@ export class SoundSprite {
|
|
|
40
45
|
* TBD.
|
|
41
46
|
* @param {string} marker - TBD.
|
|
42
47
|
*/
|
|
43
|
-
stop(marker) {
|
|
48
|
+
stop(marker: string) {
|
|
44
49
|
if (!marker) {
|
|
45
50
|
for (let key in this.sounds) {
|
|
46
51
|
this.sounds[key].stop();
|
|
@@ -55,7 +60,7 @@ export class SoundSprite {
|
|
|
55
60
|
* @param {string} marker - TBD.
|
|
56
61
|
* @returns {import('./sound.js').Sound} TBD.
|
|
57
62
|
*/
|
|
58
|
-
get(marker) {
|
|
63
|
+
get(marker: string) {
|
|
59
64
|
return this.sounds[marker];
|
|
60
65
|
}
|
|
61
66
|
}
|
package/src/phaser/core/stage.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { setTouchAction, setUserSelect } from '../display/canvas/util.js';
|
|
3
2
|
import { DisplayObject } from '../display/display_object.js';
|
|
4
3
|
import { Matrix } from '../geom/matrix.js';
|
|
@@ -6,11 +5,15 @@ import { valueToColor } from '../util/math.js';
|
|
|
6
5
|
import { SCALE_LINEAR, SCALE_NEAREST } from './const.js';
|
|
7
6
|
|
|
8
7
|
export class Stage extends DisplayObject {
|
|
8
|
+
declare name: any;
|
|
9
|
+
declare worldTransform: any;
|
|
10
|
+
currentRenderOrderID!: any;
|
|
11
|
+
_bgColor!: any;
|
|
9
12
|
/**
|
|
10
13
|
* Creates a new Stage instance.
|
|
11
14
|
* @param {import('./game.js').Game} game - The game instance.
|
|
12
15
|
*/
|
|
13
|
-
constructor(game) {
|
|
16
|
+
constructor(game: import('./game.js').Game) {
|
|
14
17
|
super(game);
|
|
15
18
|
this.name = '_stage_root';
|
|
16
19
|
this.worldTransform = new Matrix();
|
|
@@ -36,7 +39,7 @@ export class Stage extends DisplayObject {
|
|
|
36
39
|
* Sets the background color of the stage.
|
|
37
40
|
* @param {number} color - The color to set as the background.
|
|
38
41
|
*/
|
|
39
|
-
setBackgroundColor(color) {
|
|
42
|
+
setBackgroundColor(color: number) {
|
|
40
43
|
if (this.game.config.transparent) {
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
@@ -91,11 +94,12 @@ export class Stage extends DisplayObject {
|
|
|
91
94
|
/**
|
|
92
95
|
* Updates the stage's transformation matrix.
|
|
93
96
|
*/
|
|
94
|
-
updateTransform() {
|
|
97
|
+
updateTransform(): this {
|
|
95
98
|
this.worldAlpha = 1;
|
|
96
99
|
for (let i = 0; i < this.children.length; i += 1) {
|
|
97
100
|
this.children[i].updateTransform();
|
|
98
101
|
}
|
|
102
|
+
return this;
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
/**
|
package/src/phaser/core/time.ts
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Timer } from './timer.js';
|
|
3
2
|
|
|
4
3
|
export class Time {
|
|
4
|
+
game!: any;
|
|
5
|
+
time!: any;
|
|
6
|
+
prevTime!: any;
|
|
7
|
+
now!: any;
|
|
8
|
+
elapsed!: any;
|
|
9
|
+
elapsedMS!: any;
|
|
10
|
+
desiredFpsMult!: any;
|
|
11
|
+
_desiredFps!: any;
|
|
12
|
+
suggestedFps!: any;
|
|
13
|
+
advancedTiming!: any;
|
|
14
|
+
frames!: any;
|
|
15
|
+
fps!: any;
|
|
16
|
+
fpsMin!: any;
|
|
17
|
+
fpsMax!: any;
|
|
18
|
+
msMin!: any;
|
|
19
|
+
msMax!: any;
|
|
20
|
+
pauseDuration!: any;
|
|
21
|
+
timeToCall!: any;
|
|
22
|
+
timeExpected!: any;
|
|
23
|
+
events!: any;
|
|
24
|
+
_frameCount!: any;
|
|
25
|
+
_elapsedAccumulator!: any;
|
|
26
|
+
_started!: any;
|
|
27
|
+
_timeLastSecond!: any;
|
|
28
|
+
_pauseStarted!: any;
|
|
29
|
+
_justResumed!: any;
|
|
30
|
+
_timers!: any;
|
|
5
31
|
/**
|
|
6
32
|
* Creates a new Time instance.
|
|
7
33
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
8
34
|
*/
|
|
9
|
-
constructor(game) {
|
|
35
|
+
constructor(game: import('./game.js').Game) {
|
|
10
36
|
this.game = game;
|
|
11
37
|
/** @type {number} */
|
|
12
38
|
this.time = 0;
|
|
@@ -76,7 +102,7 @@ export class Time {
|
|
|
76
102
|
* @param {Timer} timer - The Timer to add.
|
|
77
103
|
* @returns {Timer} The added Timer object.
|
|
78
104
|
*/
|
|
79
|
-
add(timer) {
|
|
105
|
+
add(timer: Timer) {
|
|
80
106
|
this._timers.push(timer);
|
|
81
107
|
return timer;
|
|
82
108
|
}
|
|
@@ -86,7 +112,7 @@ export class Time {
|
|
|
86
112
|
* @param {boolean} autoDestroy - Whether the timer should be automatically destroyed when it completes.
|
|
87
113
|
* @returns {Timer} The created Timer object.
|
|
88
114
|
*/
|
|
89
|
-
create(autoDestroy = true) {
|
|
115
|
+
create(autoDestroy: boolean = true) {
|
|
90
116
|
const timer = new Timer(this.game, autoDestroy);
|
|
91
117
|
this._timers.push(timer);
|
|
92
118
|
return timer;
|
|
@@ -118,7 +144,7 @@ export class Time {
|
|
|
118
144
|
* Updates the Time manager with a new timestamp.
|
|
119
145
|
* @param {number} time - The new timestamp to use for updating.
|
|
120
146
|
*/
|
|
121
|
-
update(time) {
|
|
147
|
+
update(time: number) {
|
|
122
148
|
const previousDateNow = this.time;
|
|
123
149
|
// this.time always holds a Date.now value
|
|
124
150
|
this.time = Date.now();
|
|
@@ -227,7 +253,7 @@ export class Time {
|
|
|
227
253
|
* @param {number} since - The timestamp to calculate elapsed time from.
|
|
228
254
|
* @returns {number} The elapsed time in milliseconds.
|
|
229
255
|
*/
|
|
230
|
-
elapsedSince(since) {
|
|
256
|
+
elapsedSince(since: number) {
|
|
231
257
|
return this.time - since;
|
|
232
258
|
}
|
|
233
259
|
|
|
@@ -236,7 +262,7 @@ export class Time {
|
|
|
236
262
|
* @param {number} since - The timestamp to calculate elapsed time from.
|
|
237
263
|
* @returns {number} The elapsed time in seconds.
|
|
238
264
|
*/
|
|
239
|
-
elapsedSecondsSince(since) {
|
|
265
|
+
elapsedSecondsSince(since: number) {
|
|
240
266
|
return (this.time - since) * 0.001;
|
|
241
267
|
}
|
|
242
268
|
|