@vpmedia/phaser 1.104.0 → 1.106.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.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +164 -592
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -57
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +11 -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 +60 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- 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 -174
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +7 -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 -60
- 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 +49 -58
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +15 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +23 -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 +2 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +9 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +2 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +38 -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 +22 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +10 -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 +56 -101
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +11 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +4 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +5 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +10 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -21
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +37 -59
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +6 -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 +4 -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 +22 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +23 -35
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +2 -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 +5 -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 +45 -42
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +24 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +1 -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 -37
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +34 -49
- 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 +2 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +2 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +3 -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 +2 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +3 -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 +2 -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 +2 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +8 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +1 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +4 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +5 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +15 -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 +13 -13
- package/src/index.ts +8 -0
- package/src/phaser/core/animation.ts +46 -61
- package/src/phaser/core/animation_manager.ts +27 -21
- 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 -68
- package/src/phaser/core/device.ts +24 -25
- 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 -193
- package/src/phaser/core/factory.ts +25 -18
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -76
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +36 -63
- package/src/phaser/core/input.ts +72 -68
- package/src/phaser/core/input_handler.ts +93 -84
- package/src/phaser/core/input_mouse.ts +42 -36
- package/src/phaser/core/input_mspointer.ts +24 -25
- package/src/phaser/core/input_pointer.ts +55 -56
- package/src/phaser/core/input_touch.ts +26 -26
- package/src/phaser/core/loader.ts +108 -70
- package/src/phaser/core/loader_parser.ts +24 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -82
- package/src/phaser/core/scene.ts +3 -4
- package/src/phaser/core/scene_manager.ts +26 -26
- package/src/phaser/core/signal.ts +16 -10
- package/src/phaser/core/signal_binding.ts +9 -2
- package/src/phaser/core/sound.ts +71 -112
- package/src/phaser/core/sound_manager.ts +31 -30
- package/src/phaser/core/sound_sprite.ts +11 -12
- package/src/phaser/core/stage.ts +8 -8
- package/src/phaser/core/time.ts +34 -35
- package/src/phaser/core/timer.ts +40 -34
- package/src/phaser/core/timer_event.ts +23 -23
- package/src/phaser/core/tween.ts +62 -68
- package/src/phaser/core/tween_data.ts +31 -31
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +11 -12
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -31
- package/src/phaser/display/button.ts +34 -49
- package/src/phaser/display/canvas/buffer.ts +6 -7
- 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 -20
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +17 -9
- package/src/phaser/display/display_object.ts +49 -50
- package/src/phaser/display/graphics.ts +56 -43
- package/src/phaser/display/graphics_data.ts +19 -12
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -42
- package/src/phaser/display/image.ts +38 -52
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +17 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -8
- package/src/phaser/display/webgl/base_texture.ts +14 -15
- package/src/phaser/display/webgl/blend_manager.ts +5 -5
- package/src/phaser/display/webgl/earcut.ts +44 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -19
- package/src/phaser/display/webgl/filter_manager.ts +5 -5
- package/src/phaser/display/webgl/filter_texture.ts +7 -7
- package/src/phaser/display/webgl/graphics.ts +17 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -11
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +18 -12
- package/src/phaser/display/webgl/renderer.ts +24 -24
- package/src/phaser/display/webgl/shader/complex.ts +7 -7
- package/src/phaser/display/webgl/shader/fast.ts +8 -8
- package/src/phaser/display/webgl/shader/normal.ts +12 -12
- package/src/phaser/display/webgl/shader/primitive.ts +7 -7
- package/src/phaser/display/webgl/shader/strip.ts +7 -7
- package/src/phaser/display/webgl/shader_manager.ts +13 -13
- package/src/phaser/display/webgl/sprite_batch.ts +20 -20
- package/src/phaser/display/webgl/stencil_manager.ts +20 -8
- package/src/phaser/display/webgl/texture.ts +40 -24
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +10 -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 +27 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +22 -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,100 +1,53 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Signal } from './signal.js';
|
|
3
2
|
|
|
4
3
|
export class Sound {
|
|
5
|
-
_paused;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/** @type {AudioNode | null} */
|
|
53
|
-
externalNode;
|
|
54
|
-
/** @type {GainNode | null} */
|
|
55
|
-
masterGainNode;
|
|
56
|
-
/** @type {GainNode | null} */
|
|
57
|
-
gainNode;
|
|
58
|
-
/** @type {AudioBufferSourceNode | null} */
|
|
59
|
-
_sound;
|
|
60
|
-
/** @type {boolean} */
|
|
61
|
-
_markedToDelete;
|
|
62
|
-
/** @type {boolean} */
|
|
63
|
-
_removeFromSoundManager;
|
|
64
|
-
/** @type {Signal} */
|
|
65
|
-
onPlay;
|
|
66
|
-
/** @type {Signal} */
|
|
67
|
-
onPause;
|
|
68
|
-
/** @type {Signal} */
|
|
69
|
-
onResume;
|
|
70
|
-
/** @type {Signal} */
|
|
71
|
-
onLoop;
|
|
72
|
-
/** @type {Signal} */
|
|
73
|
-
onStop;
|
|
74
|
-
/** @type {Signal} */
|
|
75
|
-
onMute;
|
|
76
|
-
/** @type {Signal} */
|
|
77
|
-
onMarkerComplete;
|
|
78
|
-
/** @type {Signal} */
|
|
79
|
-
onFadeComplete;
|
|
80
|
-
/** @type {number} */
|
|
81
|
-
_volume;
|
|
82
|
-
/** @type {AudioBuffer | null} */
|
|
83
|
-
_buffer;
|
|
84
|
-
/** @type {boolean} */
|
|
85
|
-
_muted;
|
|
86
|
-
/** @type {string} */
|
|
87
|
-
_tempMarker;
|
|
88
|
-
/** @type {number} */
|
|
89
|
-
_tempPosition;
|
|
90
|
-
/** @type {number} */
|
|
91
|
-
_tempVolume;
|
|
92
|
-
/** @type {number} */
|
|
93
|
-
_tempPause;
|
|
94
|
-
/** @type {number} */
|
|
95
|
-
_muteVolume;
|
|
96
|
-
/** @type {boolean} */
|
|
97
|
-
_tempLoop;
|
|
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;
|
|
98
51
|
/**
|
|
99
52
|
* Creates a new Sound instance.
|
|
100
53
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
@@ -103,7 +56,13 @@ _paused;
|
|
|
103
56
|
* @param {boolean} loop - Whether the sound should loop.
|
|
104
57
|
* @param {boolean} connect - Whether to connect to the master gain node.
|
|
105
58
|
*/
|
|
106
|
-
constructor(
|
|
59
|
+
constructor(
|
|
60
|
+
game: import('./game.js').Game,
|
|
61
|
+
key: string,
|
|
62
|
+
volume: number = 1,
|
|
63
|
+
loop: boolean = false,
|
|
64
|
+
connect: boolean = null
|
|
65
|
+
) {
|
|
107
66
|
// TODO
|
|
108
67
|
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
|
|
109
68
|
if (!connect) {
|
|
@@ -145,7 +104,7 @@ _paused;
|
|
|
145
104
|
this.context = this.game.sound.context;
|
|
146
105
|
this.masterGainNode = this.game.sound.masterGain;
|
|
147
106
|
if (this.context.createGain === undefined) {
|
|
148
|
-
this.gainNode = this.context.createGainNode();
|
|
107
|
+
this.gainNode = (this.context as any).createGainNode();
|
|
149
108
|
} else {
|
|
150
109
|
this.gainNode = this.context.createGain();
|
|
151
110
|
}
|
|
@@ -178,10 +137,10 @@ _paused;
|
|
|
178
137
|
* Callback when a sound has been unlocked.
|
|
179
138
|
* @param {string} key - The key of the sound that was unlocked.
|
|
180
139
|
*/
|
|
181
|
-
soundHasUnlocked(key) {
|
|
140
|
+
soundHasUnlocked(key: string) {
|
|
182
141
|
if (key === this.key) {
|
|
183
142
|
this._sound = this.game.cache.getSoundData(this.key);
|
|
184
|
-
this.totalDuration = this._sound.duration;
|
|
143
|
+
this.totalDuration = (this._sound as any).duration;
|
|
185
144
|
}
|
|
186
145
|
}
|
|
187
146
|
|
|
@@ -193,7 +152,7 @@ _paused;
|
|
|
193
152
|
* @param {number} volume - The volume level (0.0 to 1.0) of the marker.
|
|
194
153
|
* @param {boolean} loop - Whether the marker should loop.
|
|
195
154
|
*/
|
|
196
|
-
addMarker(name, start, duration = 1, volume = 1, loop = false) {
|
|
155
|
+
addMarker(name: string, start: number, duration: number = 1, volume: number = 1, loop: boolean = false) {
|
|
197
156
|
this.markers[name] = {
|
|
198
157
|
name,
|
|
199
158
|
start,
|
|
@@ -209,7 +168,7 @@ _paused;
|
|
|
209
168
|
* Removes a marker from the sound.
|
|
210
169
|
* @param {string} name - The name of the marker to remove.
|
|
211
170
|
*/
|
|
212
|
-
removeMarker(name) {
|
|
171
|
+
removeMarker(name: string) {
|
|
213
172
|
delete this.markers[name];
|
|
214
173
|
}
|
|
215
174
|
|
|
@@ -289,7 +248,7 @@ _paused;
|
|
|
289
248
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
290
249
|
* @returns {Sound} This Sound instance for chaining.
|
|
291
250
|
*/
|
|
292
|
-
loopFull(volume) {
|
|
251
|
+
loopFull(volume: number) {
|
|
293
252
|
return this.play(null, 0, volume, true);
|
|
294
253
|
}
|
|
295
254
|
|
|
@@ -302,7 +261,7 @@ _paused;
|
|
|
302
261
|
* @param {boolean} forceRestart - Whether to force restarting the sound even if it's already playing.
|
|
303
262
|
* @returns {Sound} This Sound instance for chaining.
|
|
304
263
|
*/
|
|
305
|
-
play(marker, position, volume, loop, forceRestart = true) {
|
|
264
|
+
play(marker: any = '', position: any = 0, volume: any = 1, loop: any = false, forceRestart: boolean = true) {
|
|
306
265
|
if (marker === undefined || marker === false || marker === null) {
|
|
307
266
|
marker = '';
|
|
308
267
|
}
|
|
@@ -316,7 +275,7 @@ _paused;
|
|
|
316
275
|
}
|
|
317
276
|
if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || forceRestart)) {
|
|
318
277
|
if (this._sound.stop === undefined) {
|
|
319
|
-
this._sound.noteOff(0);
|
|
278
|
+
(this._sound as any).noteOff(0);
|
|
320
279
|
} else {
|
|
321
280
|
this._sound.stop(0);
|
|
322
281
|
}
|
|
@@ -396,7 +355,7 @@ _paused;
|
|
|
396
355
|
}
|
|
397
356
|
// Useful to cache this somewhere perhaps?
|
|
398
357
|
if (this._sound.start === undefined) {
|
|
399
|
-
this._sound.noteGrainOn(0, this.position, this.duration);
|
|
358
|
+
(this._sound as any).noteGrainOn(0, this.position, this.duration);
|
|
400
359
|
} else if (this.loop && marker === '') {
|
|
401
360
|
this._sound.start(0, 0);
|
|
402
361
|
} else {
|
|
@@ -423,7 +382,7 @@ _paused;
|
|
|
423
382
|
* @param {number} volume - The volume level (0.0 to 1.0) to play at.
|
|
424
383
|
* @param {boolean} loop - Whether the sound should loop.
|
|
425
384
|
*/
|
|
426
|
-
restart(marker = '', position = 0, volume = 1, loop = false) {
|
|
385
|
+
restart(marker: string = '', position: number = 0, volume: number = 1, loop: boolean = false) {
|
|
427
386
|
this.play(marker, position, volume, loop, true);
|
|
428
387
|
}
|
|
429
388
|
|
|
@@ -435,7 +394,7 @@ _paused;
|
|
|
435
394
|
this.paused = true;
|
|
436
395
|
this.pausedPosition = this.currentTime;
|
|
437
396
|
this.pausedTime = this.game.time.time;
|
|
438
|
-
this._tempPause = this._sound.currentTime;
|
|
397
|
+
this._tempPause = (this._sound as any).currentTime;
|
|
439
398
|
this.onPause.dispatch(this);
|
|
440
399
|
this.stop();
|
|
441
400
|
}
|
|
@@ -462,7 +421,7 @@ _paused;
|
|
|
462
421
|
}
|
|
463
422
|
const duration = this.duration - this.pausedPosition / 1000;
|
|
464
423
|
if (this._sound.start === undefined) {
|
|
465
|
-
this._sound.noteGrainOn(0, p, duration);
|
|
424
|
+
(this._sound as any).noteGrainOn(0, p, duration);
|
|
466
425
|
} else {
|
|
467
426
|
this._sound.start(0, p, duration);
|
|
468
427
|
}
|
|
@@ -479,7 +438,7 @@ _paused;
|
|
|
479
438
|
stop() {
|
|
480
439
|
if (this.isPlaying && this._sound) {
|
|
481
440
|
if (this._sound.stop === undefined) {
|
|
482
|
-
this._sound.noteOff(0);
|
|
441
|
+
(this._sound as any).noteOff(0);
|
|
483
442
|
} else {
|
|
484
443
|
this._sound.stop(0);
|
|
485
444
|
}
|
|
@@ -510,7 +469,7 @@ _paused;
|
|
|
510
469
|
* @param {boolean} loop - Whether the sound should loop.
|
|
511
470
|
* @param {string} marker - The name of the marker to fade in, or empty string to use current marker.
|
|
512
471
|
*/
|
|
513
|
-
fadeIn(duration, loop = false, marker = this.currentMarker) {
|
|
472
|
+
fadeIn(duration: number, loop: boolean = false, marker: string = this.currentMarker) {
|
|
514
473
|
if (this.paused) {
|
|
515
474
|
return;
|
|
516
475
|
}
|
|
@@ -522,7 +481,7 @@ _paused;
|
|
|
522
481
|
* Fades out the sound to silence.
|
|
523
482
|
* @param {number} duration - The fade-out duration (in milliseconds).
|
|
524
483
|
*/
|
|
525
|
-
fadeOut(duration) {
|
|
484
|
+
fadeOut(duration: number) {
|
|
526
485
|
this.fadeTo(duration, 0);
|
|
527
486
|
}
|
|
528
487
|
|
|
@@ -531,7 +490,7 @@ _paused;
|
|
|
531
490
|
* @param {number} duration - The fade duration (in milliseconds).
|
|
532
491
|
* @param {number} volume - The target volume level (0.0 to 1.0).
|
|
533
492
|
*/
|
|
534
|
-
fadeTo(duration = 100, volume = 0) {
|
|
493
|
+
fadeTo(duration: number = 100, volume: number = 0) {
|
|
535
494
|
if (!this.isPlaying || this.paused || volume === this.volume) {
|
|
536
495
|
return;
|
|
537
496
|
}
|
|
@@ -553,7 +512,7 @@ _paused;
|
|
|
553
512
|
* Destroys the sound and cleans up resources.
|
|
554
513
|
* @param {boolean} remove - Whether to remove the sound from the SoundManager.
|
|
555
514
|
*/
|
|
556
|
-
destroy(remove = true) {
|
|
515
|
+
destroy(remove: boolean = true) {
|
|
557
516
|
this._markedToDelete = true;
|
|
558
517
|
this._removeFromSoundManager = remove;
|
|
559
518
|
this.stop();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import {
|
|
3
2
|
addPageLifecycleCallback,
|
|
4
3
|
getPageLifecycleEventEmitter,
|
|
@@ -13,28 +12,30 @@ import { Sound } from './sound.js';
|
|
|
13
12
|
import { SoundSprite } from './sound_sprite.js';
|
|
14
13
|
|
|
15
14
|
export class SoundManager {
|
|
16
|
-
game;
|
|
17
|
-
onChange;
|
|
18
|
-
context;
|
|
19
|
-
baseLatency;
|
|
20
|
-
noAudio;
|
|
21
|
-
type;
|
|
22
|
-
connectToMaster;
|
|
23
|
-
isLocked;
|
|
24
|
-
_codeMuted;
|
|
25
|
-
_muted;
|
|
26
|
-
_unlockSource;
|
|
27
|
-
_volume;
|
|
28
|
-
_sounds;
|
|
29
|
-
_watchList;
|
|
30
|
-
_watching;
|
|
31
|
-
_watchCallback;
|
|
32
|
-
_watchContext;
|
|
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;
|
|
33
34
|
/**
|
|
34
35
|
* Creates a new SoundManager instance.
|
|
35
36
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
36
37
|
*/
|
|
37
|
-
constructor(game) {
|
|
38
|
+
constructor(game: import('./game.js').Game) {
|
|
38
39
|
this.game = game;
|
|
39
40
|
this.onChange = new Signal();
|
|
40
41
|
/** @type {AudioContext} */
|
|
@@ -81,10 +82,10 @@ _watchContext;
|
|
|
81
82
|
const typedError = error instanceof Error ? error : new Error(String(error));
|
|
82
83
|
this.game.logger.exception('SoundManager', typedError);
|
|
83
84
|
}
|
|
84
|
-
} else if (window.webkitAudioContext) {
|
|
85
|
+
} else if ((window as any).webkitAudioContext) {
|
|
85
86
|
try {
|
|
86
87
|
this.game.logger.info('initWebkitAudioContext');
|
|
87
|
-
this.context = new window.webkitAudioContext();
|
|
88
|
+
this.context = new (window as any).webkitAudioContext();
|
|
88
89
|
this.type = AUDIO_WEBKIT;
|
|
89
90
|
} catch (error) {
|
|
90
91
|
this.context = null;
|
|
@@ -182,7 +183,7 @@ _watchContext;
|
|
|
182
183
|
* Handles unlock events to resume audio context.
|
|
183
184
|
* @param {Event} event - The DOM event that triggered the unlock.
|
|
184
185
|
*/
|
|
185
|
-
onUnlockEvent = (event) => {
|
|
186
|
+
onUnlockEvent = (event: Event) => {
|
|
186
187
|
const initialState = this.context.state;
|
|
187
188
|
if (initialState !== 'suspended' && initialState !== 'interrupted') {
|
|
188
189
|
this.game.logger.info('onUnlockResumeDenied', {
|
|
@@ -268,7 +269,7 @@ _watchContext;
|
|
|
268
269
|
* Decodes an audio file for playback.
|
|
269
270
|
* @param {string} key - The key of the sound to decode.
|
|
270
271
|
*/
|
|
271
|
-
decode(key) {
|
|
272
|
+
decode(key: string) {
|
|
272
273
|
const soundData = this.game.cache.getSoundData(key);
|
|
273
274
|
if (!soundData) {
|
|
274
275
|
return;
|
|
@@ -301,7 +302,7 @@ _watchContext;
|
|
|
301
302
|
* @param {Function} callback - The callback function to call when all files are decoded.
|
|
302
303
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
303
304
|
*/
|
|
304
|
-
setDecodedCallback(files, callback, callbackContext) {
|
|
305
|
+
setDecodedCallback(files: any, callback: Function, callbackContext: any) {
|
|
305
306
|
if (typeof files === 'string') {
|
|
306
307
|
files = [files];
|
|
307
308
|
}
|
|
@@ -360,7 +361,7 @@ _watchContext;
|
|
|
360
361
|
* @param {boolean} connect - Whether to connect to the master gain node.
|
|
361
362
|
* @returns {Sound} The created Sound object.
|
|
362
363
|
*/
|
|
363
|
-
add(key, volume = 1, loop = false, connect = this.connectToMaster) {
|
|
364
|
+
add(key: string, volume: number = 1, loop: boolean = false, connect: boolean = this.connectToMaster) {
|
|
364
365
|
const sound = new Sound(this.game, key, volume, loop, connect);
|
|
365
366
|
this._sounds.push(sound);
|
|
366
367
|
return sound;
|
|
@@ -371,7 +372,7 @@ _watchContext;
|
|
|
371
372
|
* @param {string} key - The key of the sound sprite to add.
|
|
372
373
|
* @returns {SoundSprite} The created SoundSprite object.
|
|
373
374
|
*/
|
|
374
|
-
addSprite(key) {
|
|
375
|
+
addSprite(key: string) {
|
|
375
376
|
return new SoundSprite(this.game, key);
|
|
376
377
|
}
|
|
377
378
|
|
|
@@ -380,7 +381,7 @@ _watchContext;
|
|
|
380
381
|
* @param {Sound | null | undefined} sound - The sound object to remove.
|
|
381
382
|
* @returns {boolean} True if the sound was removed, false otherwise.
|
|
382
383
|
*/
|
|
383
|
-
remove(sound) {
|
|
384
|
+
remove(sound: Sound | null | undefined) {
|
|
384
385
|
let i = this._sounds.length;
|
|
385
386
|
while (i) {
|
|
386
387
|
i -= 1;
|
|
@@ -398,7 +399,7 @@ _watchContext;
|
|
|
398
399
|
* @param {string} key - The key of sounds to remove.
|
|
399
400
|
* @returns {number} The number of sounds removed.
|
|
400
401
|
*/
|
|
401
|
-
removeByKey(key) {
|
|
402
|
+
removeByKey(key: string) {
|
|
402
403
|
let i = this._sounds.length;
|
|
403
404
|
let removed = 0;
|
|
404
405
|
while (i) {
|
|
@@ -419,7 +420,7 @@ _watchContext;
|
|
|
419
420
|
* @param {boolean} loop - Whether the sound should loop.
|
|
420
421
|
* @returns {Sound} The created Sound object, or null if audio is disabled.
|
|
421
422
|
*/
|
|
422
|
-
play(key, volume = 1, loop = false) {
|
|
423
|
+
play(key: string, volume: number = 1, loop: boolean = false) {
|
|
423
424
|
if (this.noAudio) {
|
|
424
425
|
return null;
|
|
425
426
|
}
|
|
@@ -525,4 +526,4 @@ _watchContext;
|
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
}
|
|
528
|
-
}
|
|
529
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
export class SoundSprite {
|
|
3
|
-
game;
|
|
4
|
-
key;
|
|
5
|
-
config;
|
|
6
|
-
autoplayKey;
|
|
7
|
-
autoplay;
|
|
8
|
-
sounds;
|
|
2
|
+
game!: any;
|
|
3
|
+
key!: any;
|
|
4
|
+
config!: any;
|
|
5
|
+
autoplayKey!: any;
|
|
6
|
+
autoplay!: any;
|
|
7
|
+
sounds!: any;
|
|
9
8
|
/**
|
|
10
9
|
* TBD.
|
|
11
10
|
* @param {import('./game.js').Game} game - TBD.
|
|
12
11
|
* @param {string} key - TBD.
|
|
13
12
|
*/
|
|
14
|
-
constructor(game, key) {
|
|
13
|
+
constructor(game: import('./game.js').Game, key: string) {
|
|
15
14
|
this.game = game;
|
|
16
15
|
this.key = key;
|
|
17
16
|
this.config = this.game.cache.getJSON(`${key}-audioatlas`);
|
|
@@ -38,7 +37,7 @@ sounds;
|
|
|
38
37
|
* @param {number} volume - TBD.
|
|
39
38
|
* @returns {import('./sound.js').Sound} TBD.
|
|
40
39
|
*/
|
|
41
|
-
play(marker, volume = 1) {
|
|
40
|
+
play(marker: string, volume: number = 1) {
|
|
42
41
|
return this.sounds[marker].play(marker, null, volume);
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -46,7 +45,7 @@ sounds;
|
|
|
46
45
|
* TBD.
|
|
47
46
|
* @param {string} marker - TBD.
|
|
48
47
|
*/
|
|
49
|
-
stop(marker) {
|
|
48
|
+
stop(marker: string) {
|
|
50
49
|
if (!marker) {
|
|
51
50
|
for (let key in this.sounds) {
|
|
52
51
|
this.sounds[key].stop();
|
|
@@ -61,7 +60,7 @@ sounds;
|
|
|
61
60
|
* @param {string} marker - TBD.
|
|
62
61
|
* @returns {import('./sound.js').Sound} TBD.
|
|
63
62
|
*/
|
|
64
|
-
get(marker) {
|
|
63
|
+
get(marker: string) {
|
|
65
64
|
return this.sounds[marker];
|
|
66
65
|
}
|
|
67
|
-
}
|
|
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,15 +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 {
|
|
9
|
-
name;
|
|
10
|
-
worldTransform;
|
|
11
|
-
currentRenderOrderID;
|
|
12
|
-
_bgColor;
|
|
8
|
+
declare name: any;
|
|
9
|
+
declare worldTransform: any;
|
|
10
|
+
currentRenderOrderID!: any;
|
|
11
|
+
_bgColor!: any;
|
|
13
12
|
/**
|
|
14
13
|
* Creates a new Stage instance.
|
|
15
14
|
* @param {import('./game.js').Game} game - The game instance.
|
|
16
15
|
*/
|
|
17
|
-
constructor(game) {
|
|
16
|
+
constructor(game: import('./game.js').Game) {
|
|
18
17
|
super(game);
|
|
19
18
|
this.name = '_stage_root';
|
|
20
19
|
this.worldTransform = new Matrix();
|
|
@@ -40,7 +39,7 @@ _bgColor;
|
|
|
40
39
|
* Sets the background color of the stage.
|
|
41
40
|
* @param {number} color - The color to set as the background.
|
|
42
41
|
*/
|
|
43
|
-
setBackgroundColor(color) {
|
|
42
|
+
setBackgroundColor(color: number) {
|
|
44
43
|
if (this.game.config.transparent) {
|
|
45
44
|
return;
|
|
46
45
|
}
|
|
@@ -95,11 +94,12 @@ _bgColor;
|
|
|
95
94
|
/**
|
|
96
95
|
* Updates the stage's transformation matrix.
|
|
97
96
|
*/
|
|
98
|
-
updateTransform() {
|
|
97
|
+
updateTransform(): this {
|
|
99
98
|
this.worldAlpha = 1;
|
|
100
99
|
for (let i = 0; i < this.children.length; i += 1) {
|
|
101
100
|
this.children[i].updateTransform();
|
|
102
101
|
}
|
|
102
|
+
return this;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
package/src/phaser/core/time.ts
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Timer } from './timer.js';
|
|
3
2
|
|
|
4
3
|
export class Time {
|
|
5
|
-
game;
|
|
6
|
-
time;
|
|
7
|
-
prevTime;
|
|
8
|
-
now;
|
|
9
|
-
elapsed;
|
|
10
|
-
elapsedMS;
|
|
11
|
-
desiredFpsMult;
|
|
12
|
-
_desiredFps;
|
|
13
|
-
suggestedFps;
|
|
14
|
-
advancedTiming;
|
|
15
|
-
frames;
|
|
16
|
-
fps;
|
|
17
|
-
fpsMin;
|
|
18
|
-
fpsMax;
|
|
19
|
-
msMin;
|
|
20
|
-
msMax;
|
|
21
|
-
pauseDuration;
|
|
22
|
-
timeToCall;
|
|
23
|
-
timeExpected;
|
|
24
|
-
events;
|
|
25
|
-
_frameCount;
|
|
26
|
-
_elapsedAccumulator;
|
|
27
|
-
_started;
|
|
28
|
-
_timeLastSecond;
|
|
29
|
-
_pauseStarted;
|
|
30
|
-
_justResumed;
|
|
31
|
-
_timers;
|
|
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;
|
|
32
31
|
/**
|
|
33
32
|
* Creates a new Time instance.
|
|
34
33
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
35
34
|
*/
|
|
36
|
-
constructor(game) {
|
|
35
|
+
constructor(game: import('./game.js').Game) {
|
|
37
36
|
this.game = game;
|
|
38
37
|
/** @type {number} */
|
|
39
38
|
this.time = 0;
|
|
@@ -103,7 +102,7 @@ _timers;
|
|
|
103
102
|
* @param {Timer} timer - The Timer to add.
|
|
104
103
|
* @returns {Timer} The added Timer object.
|
|
105
104
|
*/
|
|
106
|
-
add(timer) {
|
|
105
|
+
add(timer: Timer) {
|
|
107
106
|
this._timers.push(timer);
|
|
108
107
|
return timer;
|
|
109
108
|
}
|
|
@@ -113,7 +112,7 @@ _timers;
|
|
|
113
112
|
* @param {boolean} autoDestroy - Whether the timer should be automatically destroyed when it completes.
|
|
114
113
|
* @returns {Timer} The created Timer object.
|
|
115
114
|
*/
|
|
116
|
-
create(autoDestroy = true) {
|
|
115
|
+
create(autoDestroy: boolean = true) {
|
|
117
116
|
const timer = new Timer(this.game, autoDestroy);
|
|
118
117
|
this._timers.push(timer);
|
|
119
118
|
return timer;
|
|
@@ -145,7 +144,7 @@ _timers;
|
|
|
145
144
|
* Updates the Time manager with a new timestamp.
|
|
146
145
|
* @param {number} time - The new timestamp to use for updating.
|
|
147
146
|
*/
|
|
148
|
-
update(time) {
|
|
147
|
+
update(time: number) {
|
|
149
148
|
const previousDateNow = this.time;
|
|
150
149
|
// this.time always holds a Date.now value
|
|
151
150
|
this.time = Date.now();
|
|
@@ -254,7 +253,7 @@ _timers;
|
|
|
254
253
|
* @param {number} since - The timestamp to calculate elapsed time from.
|
|
255
254
|
* @returns {number} The elapsed time in milliseconds.
|
|
256
255
|
*/
|
|
257
|
-
elapsedSince(since) {
|
|
256
|
+
elapsedSince(since: number) {
|
|
258
257
|
return this.time - since;
|
|
259
258
|
}
|
|
260
259
|
|
|
@@ -263,7 +262,7 @@ _timers;
|
|
|
263
262
|
* @param {number} since - The timestamp to calculate elapsed time from.
|
|
264
263
|
* @returns {number} The elapsed time in seconds.
|
|
265
264
|
*/
|
|
266
|
-
elapsedSecondsSince(since) {
|
|
265
|
+
elapsedSecondsSince(since: number) {
|
|
267
266
|
return (this.time - since) * 0.001;
|
|
268
267
|
}
|
|
269
268
|
|
|
@@ -297,4 +296,4 @@ _timers;
|
|
|
297
296
|
this._desiredFps = value;
|
|
298
297
|
this.desiredFpsMult = 1 / value;
|
|
299
298
|
}
|
|
300
|
-
}
|
|
299
|
+
}
|