@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/timer.ts
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Signal } from './signal.js';
|
|
3
2
|
import { TimerEvent } from './timer_event.js';
|
|
4
3
|
|
|
5
4
|
export class Timer {
|
|
5
|
+
game!: any;
|
|
6
|
+
running!: any;
|
|
7
|
+
autoDestroy!: any;
|
|
8
|
+
expired!: any;
|
|
9
|
+
elapsed!: any;
|
|
10
|
+
events!: any;
|
|
11
|
+
onComplete!: any;
|
|
12
|
+
nextTick!: any;
|
|
13
|
+
timeCap!: any;
|
|
14
|
+
paused!: any;
|
|
15
|
+
_codePaused!: any;
|
|
16
|
+
_started!: any;
|
|
17
|
+
_pauseStarted!: any;
|
|
18
|
+
_pauseTotal!: any;
|
|
19
|
+
_now!: any;
|
|
20
|
+
_len!: any;
|
|
21
|
+
_marked!: any;
|
|
22
|
+
_i!: any;
|
|
23
|
+
_diff!: any;
|
|
24
|
+
_newTick!: any;
|
|
6
25
|
/**
|
|
7
26
|
* Creates a new Timer instance.
|
|
8
27
|
* @param {import('./game.js').Game} game - The game instance.
|
|
9
28
|
* @param {boolean} autoDestroy - Whether to automatically destroy the timer when it completes.
|
|
10
29
|
*/
|
|
11
|
-
constructor(game, autoDestroy = false) {
|
|
30
|
+
constructor(game: import('./game.js').Game, autoDestroy: boolean = false) {
|
|
12
31
|
this.game = game;
|
|
13
32
|
/** @type {boolean} */
|
|
14
33
|
this.running = false;
|
|
@@ -60,7 +79,14 @@ export class Timer {
|
|
|
60
79
|
* @param {...any} args - Arguments to pass to the callback function.
|
|
61
80
|
* @returns {TimerEvent} The created TimerEvent.
|
|
62
81
|
*/
|
|
63
|
-
create(
|
|
82
|
+
create(
|
|
83
|
+
delay: number,
|
|
84
|
+
loop: boolean,
|
|
85
|
+
repeatCount: number,
|
|
86
|
+
callback: Function,
|
|
87
|
+
callbackContext: any = null,
|
|
88
|
+
args: any = []
|
|
89
|
+
) {
|
|
64
90
|
const roundedDelay = Math.round(delay);
|
|
65
91
|
let tick = roundedDelay;
|
|
66
92
|
if (this._now === 0) {
|
|
@@ -83,7 +109,7 @@ export class Timer {
|
|
|
83
109
|
* @param {...any} args - Arguments to pass to the callback function.
|
|
84
110
|
* @returns {TimerEvent} The created TimerEvent.
|
|
85
111
|
*/
|
|
86
|
-
add(delay, callback, callbackContext = null, ...args) {
|
|
112
|
+
add(delay: number, callback: Function, callbackContext: any = null, ...args: any[]) {
|
|
87
113
|
return this.create(delay, false, 0, callback, callbackContext, args);
|
|
88
114
|
}
|
|
89
115
|
|
|
@@ -94,7 +120,7 @@ export class Timer {
|
|
|
94
120
|
* @param {...T} args - Arguments to pass to the resolve function.
|
|
95
121
|
* @returns {Promise<T | T[]>} The created Promise.
|
|
96
122
|
*/
|
|
97
|
-
wait(delay, ...args) {
|
|
123
|
+
wait(delay: number, ...args: any[]) {
|
|
98
124
|
return new Promise((resolve) => {
|
|
99
125
|
this.create(delay, false, 0, () => {
|
|
100
126
|
resolve(args.length <= 1 ? args[0] : args);
|
|
@@ -111,7 +137,7 @@ export class Timer {
|
|
|
111
137
|
* @param {...any} args - Arguments to pass to the callback function.
|
|
112
138
|
* @returns {TimerEvent} The created TimerEvent.
|
|
113
139
|
*/
|
|
114
|
-
repeat(delay, repeatCount, callback, callbackContext = null, ...args) {
|
|
140
|
+
repeat(delay: number, repeatCount: number, callback: Function, callbackContext: any = null, ...args: any[]) {
|
|
115
141
|
return this.create(delay, false, repeatCount, callback, callbackContext, args);
|
|
116
142
|
}
|
|
117
143
|
|
|
@@ -123,7 +149,7 @@ export class Timer {
|
|
|
123
149
|
* @param {...any} args - Arguments to pass to the callback function.
|
|
124
150
|
* @returns {TimerEvent} The created TimerEvent.
|
|
125
151
|
*/
|
|
126
|
-
loop(delay, callback, callbackContext = null, ...args) {
|
|
152
|
+
loop(delay: number, callback: Function, callbackContext: any = null, ...args: any[]) {
|
|
127
153
|
return this.create(delay, true, 0, callback, callbackContext, args);
|
|
128
154
|
}
|
|
129
155
|
|
|
@@ -131,7 +157,7 @@ export class Timer {
|
|
|
131
157
|
* Starts the timer.
|
|
132
158
|
* @param {number} delay - The delay in milliseconds before starting (optional).
|
|
133
159
|
*/
|
|
134
|
-
start(delay = 0) {
|
|
160
|
+
start(delay: number = 0) {
|
|
135
161
|
if (this.running) {
|
|
136
162
|
return;
|
|
137
163
|
}
|
|
@@ -146,7 +172,7 @@ export class Timer {
|
|
|
146
172
|
* Stops the timer.
|
|
147
173
|
* @param {boolean} clearEvents - Whether to clear all events (default: true).
|
|
148
174
|
*/
|
|
149
|
-
stop(clearEvents = true) {
|
|
175
|
+
stop(clearEvents: boolean = true) {
|
|
150
176
|
this.running = false;
|
|
151
177
|
if (clearEvents) {
|
|
152
178
|
this.events.length = 0;
|
|
@@ -158,7 +184,7 @@ export class Timer {
|
|
|
158
184
|
* @param {TimerEvent | null | undefined} event - The TimerEvent to remove.
|
|
159
185
|
* @returns {boolean} True if the event was removed, false otherwise.
|
|
160
186
|
*/
|
|
161
|
-
remove(event) {
|
|
187
|
+
remove(event: TimerEvent | null | undefined) {
|
|
162
188
|
for (let i = 0; i < this.events.length; i += 1) {
|
|
163
189
|
if (this.events[i] === event) {
|
|
164
190
|
this.events[i].pendingDelete = true;
|
|
@@ -185,7 +211,7 @@ export class Timer {
|
|
|
185
211
|
* @param {TimerEvent} b - Second TimerEvent to compare.
|
|
186
212
|
* @returns {number} Comparison result (-1, 0, or 1).
|
|
187
213
|
*/
|
|
188
|
-
sortHandler(a, b) {
|
|
214
|
+
sortHandler(a: TimerEvent, b: TimerEvent) {
|
|
189
215
|
if (a.tick < b.tick) {
|
|
190
216
|
return -1;
|
|
191
217
|
} else if (a.tick > b.tick) {
|
|
@@ -214,7 +240,7 @@ export class Timer {
|
|
|
214
240
|
* @param {number} time - The current time in milliseconds.
|
|
215
241
|
* @returns {boolean} True if the timer should continue running, false if it should be destroyed.
|
|
216
242
|
*/
|
|
217
|
-
update(time) {
|
|
243
|
+
update(time: number) {
|
|
218
244
|
if (this.paused) {
|
|
219
245
|
return true;
|
|
220
246
|
}
|
|
@@ -299,7 +325,7 @@ export class Timer {
|
|
|
299
325
|
* Adjusts timer events when time has jumped (e.g., when tab is switched).
|
|
300
326
|
* @param {number} baseTime - The time to adjust from.
|
|
301
327
|
*/
|
|
302
|
-
adjustEvents(baseTime) {
|
|
328
|
+
adjustEvents(baseTime: number) {
|
|
303
329
|
for (let i = 0; i < this.events.length; i += 1) {
|
|
304
330
|
if (!this.events[i].pendingDelete) {
|
|
305
331
|
// Work out how long there would have been from when the game paused until the events next tick
|
|
@@ -413,4 +439,4 @@ export class Timer {
|
|
|
413
439
|
}
|
|
414
440
|
return 0;
|
|
415
441
|
}
|
|
416
|
-
}
|
|
442
|
+
}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Timer } from './timer.js';
|
|
2
|
+
|
|
2
3
|
export class TimerEvent {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
timer: Timer;
|
|
5
|
+
delay: number;
|
|
6
|
+
tick: number;
|
|
7
|
+
repeatCount: number;
|
|
8
|
+
loop: boolean;
|
|
9
|
+
callback: Function;
|
|
10
|
+
callbackContext: object;
|
|
11
|
+
args: unknown[];
|
|
12
|
+
pendingDelete: boolean;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
timer: Timer,
|
|
16
|
+
delay: number,
|
|
17
|
+
tick: number,
|
|
18
|
+
repeatCount: number,
|
|
19
|
+
loop: boolean,
|
|
20
|
+
callback: Function,
|
|
21
|
+
callbackContext: object,
|
|
22
|
+
args: unknown[]
|
|
23
|
+
) {
|
|
15
24
|
this.timer = timer;
|
|
16
25
|
this.delay = delay;
|
|
17
26
|
this.tick = tick;
|
|
@@ -22,4 +31,4 @@ export class TimerEvent {
|
|
|
22
31
|
this.args = args;
|
|
23
32
|
this.pendingDelete = false;
|
|
24
33
|
}
|
|
25
|
-
}
|
|
34
|
+
}
|
package/src/phaser/core/tween.ts
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import * as MathUtils from '../util/math.js';
|
|
3
2
|
import { TWEEN_COMPLETE, TWEEN_LOOPED, TWEEN_PENDING, TWEEN_RUNNING } from './const.js';
|
|
4
3
|
import { Signal } from './signal.js';
|
|
5
4
|
import { TweenData } from './tween_data.js';
|
|
6
5
|
|
|
7
6
|
export class Tween {
|
|
7
|
+
game!: import('./game.js').Game;
|
|
8
|
+
target!: import('../display/display_object.js').DisplayObject;
|
|
9
|
+
manager!: import('./tween_manager.js').TweenManager;
|
|
10
|
+
timeline!: TweenData[];
|
|
11
|
+
reverse!: boolean;
|
|
12
|
+
timeScale!: number;
|
|
13
|
+
repeatCounter!: number;
|
|
14
|
+
pendingDelete!: boolean;
|
|
15
|
+
onStart!: Signal;
|
|
16
|
+
onLoop!: Signal;
|
|
17
|
+
onRepeat!: Signal;
|
|
18
|
+
onChildComplete!: Signal;
|
|
19
|
+
onComplete!: Signal;
|
|
20
|
+
isRunning!: boolean;
|
|
21
|
+
current!: number;
|
|
22
|
+
properties!: any;
|
|
23
|
+
chainedTween!: Tween | null;
|
|
24
|
+
isPaused!: boolean;
|
|
25
|
+
_onUpdateCallback!: Function | null;
|
|
26
|
+
_onUpdateCallbackContext!: object | null;
|
|
27
|
+
_pausedTime!: number;
|
|
28
|
+
_codePaused!: boolean;
|
|
29
|
+
_hasStarted!: boolean;
|
|
8
30
|
/**
|
|
9
31
|
* Creates a new Tween instance.
|
|
10
32
|
* @param {import('../display/display_object.js').DisplayObject} target - The object to tween.
|
|
11
33
|
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
12
34
|
* @param {import('./tween_manager.js').TweenManager} manager - Reference to the Tween Manager.
|
|
13
35
|
*/
|
|
14
|
-
constructor(target, game, manager) {
|
|
36
|
+
constructor(target: import('../display/display_object.js').DisplayObject, game: import('./game.js').Game, manager: import('./tween_manager.js').TweenManager) {
|
|
15
37
|
this.game = game;
|
|
16
38
|
this.target = target;
|
|
17
39
|
/** @type {import('./tween_manager.js').TweenManager} */
|
|
@@ -65,14 +87,13 @@ export class Tween {
|
|
|
65
87
|
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
66
88
|
* @returns {Tween} This Tween object for chaining.
|
|
67
89
|
*/
|
|
68
|
-
to(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
90
|
+
to(properties: any, duration: number = 1000, ease: string | Function = 'Linear', autoStart: boolean = false, delay: number = 0, repeat: number = 0, yoyo: boolean = false) {
|
|
69
91
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
70
92
|
ease = this.manager.easeMap[ease];
|
|
71
93
|
}
|
|
72
94
|
if (this.isRunning) {
|
|
73
95
|
return this;
|
|
74
96
|
}
|
|
75
|
-
// @ts-ignore
|
|
76
97
|
this.timeline.push(new TweenData(this).to(properties, duration, ease, delay, repeat, yoyo));
|
|
77
98
|
if (autoStart) {
|
|
78
99
|
this.start();
|
|
@@ -91,7 +112,7 @@ export class Tween {
|
|
|
91
112
|
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
92
113
|
* @returns {Tween} This Tween object for chaining.
|
|
93
114
|
*/
|
|
94
|
-
from(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
115
|
+
from(properties: any, duration: number = 1000, ease: string | Function = 'Linear', autoStart: boolean = false, delay: number = 0, repeat: number = 0, yoyo: boolean = false) {
|
|
95
116
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
96
117
|
ease = this.manager.easeMap[ease];
|
|
97
118
|
}
|
|
@@ -99,7 +120,6 @@ export class Tween {
|
|
|
99
120
|
this.game.logger.warn('Tween.from cannot be called after Tween.start');
|
|
100
121
|
return this;
|
|
101
122
|
}
|
|
102
|
-
// @ts-ignore
|
|
103
123
|
this.timeline.push(new TweenData(this).from(properties, duration, ease, delay, repeat, yoyo));
|
|
104
124
|
if (autoStart) {
|
|
105
125
|
this.start();
|
|
@@ -112,7 +132,7 @@ export class Tween {
|
|
|
112
132
|
* @param {number} index - The index to start from in the timeline.
|
|
113
133
|
* @returns {Tween} This Tween object for chaining.
|
|
114
134
|
*/
|
|
115
|
-
start(index = 0) {
|
|
135
|
+
start(index: number = 0) {
|
|
116
136
|
if (this.game === null || this.target === null || this.timeline.length === 0 || this.isRunning) {
|
|
117
137
|
return this;
|
|
118
138
|
}
|
|
@@ -147,7 +167,7 @@ export class Tween {
|
|
|
147
167
|
* @param {boolean} complete - Whether to dispatch the complete event.
|
|
148
168
|
* @returns {Tween} This Tween object for chaining.
|
|
149
169
|
*/
|
|
150
|
-
stop(complete = false) {
|
|
170
|
+
stop(complete: boolean = false) {
|
|
151
171
|
this.isRunning = false;
|
|
152
172
|
this._onUpdateCallback = null;
|
|
153
173
|
this._onUpdateCallbackContext = null;
|
|
@@ -169,7 +189,7 @@ export class Tween {
|
|
|
169
189
|
* @param {number} index - The index in the timeline to update.
|
|
170
190
|
* @returns {Tween} This Tween object for chaining.
|
|
171
191
|
*/
|
|
172
|
-
updateTweenData(property, value, index = 0) {
|
|
192
|
+
updateTweenData(property: string, value: any, index: number = 0) {
|
|
173
193
|
if (this.timeline.length === 0) {
|
|
174
194
|
return this;
|
|
175
195
|
}
|
|
@@ -189,7 +209,7 @@ export class Tween {
|
|
|
189
209
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
190
210
|
* @returns {Tween} This Tween object for chaining.
|
|
191
211
|
*/
|
|
192
|
-
delay(duration, index) {
|
|
212
|
+
delay(duration: number, index: number) {
|
|
193
213
|
return this.updateTweenData('delay', duration, index);
|
|
194
214
|
}
|
|
195
215
|
|
|
@@ -200,7 +220,7 @@ export class Tween {
|
|
|
200
220
|
* @param {number} index - The index in the timeline to apply the repeat to.
|
|
201
221
|
* @returns {Tween} This Tween object for chaining.
|
|
202
222
|
*/
|
|
203
|
-
repeat(total, repeatDelay = 0, index = 0) {
|
|
223
|
+
repeat(total: number, repeatDelay: number = 0, index: number = 0) {
|
|
204
224
|
this.updateTweenData('repeatCounter', total, index);
|
|
205
225
|
return this.updateTweenData('repeatDelay', repeatDelay, index);
|
|
206
226
|
}
|
|
@@ -211,7 +231,7 @@ export class Tween {
|
|
|
211
231
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
212
232
|
* @returns {Tween} This Tween object for chaining.
|
|
213
233
|
*/
|
|
214
|
-
repeatDelay(duration, index) {
|
|
234
|
+
repeatDelay(duration: number, index: number) {
|
|
215
235
|
return this.updateTweenData('repeatDelay', duration, index);
|
|
216
236
|
}
|
|
217
237
|
|
|
@@ -222,7 +242,7 @@ export class Tween {
|
|
|
222
242
|
* @param {number} index - The index in the timeline to apply yoyo to.
|
|
223
243
|
* @returns {Tween} This Tween object for chaining.
|
|
224
244
|
*/
|
|
225
|
-
yoyo(enable, yoyoDelay = 0, index = 0) {
|
|
245
|
+
yoyo(enable: boolean, yoyoDelay: number = 0, index: number = 0) {
|
|
226
246
|
this.updateTweenData('yoyo', enable, index);
|
|
227
247
|
return this.updateTweenData('yoyoDelay', yoyoDelay, index);
|
|
228
248
|
}
|
|
@@ -233,7 +253,7 @@ export class Tween {
|
|
|
233
253
|
* @param {number} index - The index in the timeline to apply the delay to.
|
|
234
254
|
* @returns {Tween} This Tween object for chaining.
|
|
235
255
|
*/
|
|
236
|
-
yoyoDelay(duration, index) {
|
|
256
|
+
yoyoDelay(duration: number, index: number) {
|
|
237
257
|
return this.updateTweenData('yoyoDelay', duration, index);
|
|
238
258
|
}
|
|
239
259
|
|
|
@@ -243,7 +263,7 @@ export class Tween {
|
|
|
243
263
|
* @param {number} index - The index in the timeline to apply easing to.
|
|
244
264
|
* @returns {Tween} This Tween object for chaining.
|
|
245
265
|
*/
|
|
246
|
-
easing(ease, index) {
|
|
266
|
+
easing(ease: string|Function, index: number) {
|
|
247
267
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
248
268
|
ease = this.manager.easeMap[ease];
|
|
249
269
|
}
|
|
@@ -257,7 +277,7 @@ export class Tween {
|
|
|
257
277
|
* @param {number} index - The index in the timeline to apply interpolation to.
|
|
258
278
|
* @returns {Tween} This Tween object for chaining.
|
|
259
279
|
*/
|
|
260
|
-
interpolation(interpolation, context = MathUtils, index = 0) {
|
|
280
|
+
interpolation(interpolation: Function, context: any = MathUtils, index: number = 0) {
|
|
261
281
|
this.updateTweenData('interpolationFunction', interpolation, index);
|
|
262
282
|
return this.updateTweenData('interpolationContext', context, index);
|
|
263
283
|
}
|
|
@@ -267,7 +287,7 @@ export class Tween {
|
|
|
267
287
|
* @param {number} total - The number of times to repeat (-1 for infinite).
|
|
268
288
|
* @returns {Tween} This Tween object for chaining.
|
|
269
289
|
*/
|
|
270
|
-
repeatAll(total = 0) {
|
|
290
|
+
repeatAll(total: number = 0) {
|
|
271
291
|
this.repeatCounter = total;
|
|
272
292
|
return this;
|
|
273
293
|
}
|
|
@@ -277,7 +297,7 @@ export class Tween {
|
|
|
277
297
|
* @param {...any} args - The tweens to chain.
|
|
278
298
|
* @returns {Tween} This Tween object for chaining.
|
|
279
299
|
*/
|
|
280
|
-
chain(...args) {
|
|
300
|
+
chain(...args: any[]) {
|
|
281
301
|
let i = args.length;
|
|
282
302
|
while (i) {
|
|
283
303
|
i -= 1;
|
|
@@ -295,7 +315,7 @@ export class Tween {
|
|
|
295
315
|
* @param {boolean} value - Whether to loop infinitely.
|
|
296
316
|
* @returns {Tween} This Tween object for chaining.
|
|
297
317
|
*/
|
|
298
|
-
loop(value = true) {
|
|
318
|
+
loop(value: boolean = true) {
|
|
299
319
|
this.repeatCounter = value ? -1 : 0;
|
|
300
320
|
return this;
|
|
301
321
|
}
|
|
@@ -306,7 +326,7 @@ export class Tween {
|
|
|
306
326
|
* @param {object} callbackContext - The context in which to call the callback.
|
|
307
327
|
* @returns {Tween} This Tween object for chaining.
|
|
308
328
|
*/
|
|
309
|
-
onUpdateCallback(callback, callbackContext) {
|
|
329
|
+
onUpdateCallback(callback: Function, callbackContext: any) {
|
|
310
330
|
this._onUpdateCallback = callback;
|
|
311
331
|
this._onUpdateCallbackContext = callbackContext;
|
|
312
332
|
return this;
|
|
@@ -360,7 +380,7 @@ export class Tween {
|
|
|
360
380
|
* @param {number} time - The current game time.
|
|
361
381
|
* @returns {boolean} True if the tween should continue running, false if it's complete.
|
|
362
382
|
*/
|
|
363
|
-
update(time) {
|
|
383
|
+
update(time: number) {
|
|
364
384
|
if (this.pendingDelete || !this.target) {
|
|
365
385
|
return false;
|
|
366
386
|
}
|
|
@@ -444,7 +464,7 @@ export class Tween {
|
|
|
444
464
|
* @param {object[]} data - The array to store the generated data in.
|
|
445
465
|
* @returns {object[]} The populated data array.
|
|
446
466
|
*/
|
|
447
|
-
generateData(frameRate = 60, data = []) {
|
|
467
|
+
generateData(frameRate: number = 60, data: any[] = []) {
|
|
448
468
|
if (this.game === null || this.target === null) {
|
|
449
469
|
return null;
|
|
450
470
|
}
|
|
@@ -481,4 +501,4 @@ export class Tween {
|
|
|
481
501
|
}
|
|
482
502
|
return total;
|
|
483
503
|
}
|
|
484
|
-
}
|
|
504
|
+
}
|
|
@@ -1,13 +1,37 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import * as MathUtils from '../util/math.js';
|
|
3
2
|
import { TWEEN_COMPLETE, TWEEN_LOOPED, TWEEN_PENDING, TWEEN_RUNNING } from './const.js';
|
|
4
3
|
|
|
5
4
|
export class TweenData {
|
|
5
|
+
parent!: any;
|
|
6
|
+
game!: any;
|
|
7
|
+
vStart!: any;
|
|
8
|
+
vStartCache!: any;
|
|
9
|
+
vEnd!: any;
|
|
10
|
+
vEndCache!: any;
|
|
11
|
+
duration!: any;
|
|
12
|
+
percent!: any;
|
|
13
|
+
value!: any;
|
|
14
|
+
repeatCounter!: any;
|
|
15
|
+
repeatDelay!: any;
|
|
16
|
+
repeatTotal!: any;
|
|
17
|
+
interpolate!: any;
|
|
18
|
+
yoyo!: any;
|
|
19
|
+
yoyoDelay!: any;
|
|
20
|
+
inReverse!: any;
|
|
21
|
+
delay!: any;
|
|
22
|
+
dt!: any;
|
|
23
|
+
startTime!: any;
|
|
24
|
+
easingFunction!: any;
|
|
25
|
+
interpolationFunction!: any;
|
|
26
|
+
interpolationContext!: any;
|
|
27
|
+
isRunning!: any;
|
|
28
|
+
isFrom!: any;
|
|
29
|
+
yoyoCounter!: any;
|
|
6
30
|
/**
|
|
7
31
|
* Creates a new TweenData instance.
|
|
8
32
|
* @param {import('./tween.js').Tween} parent - The parent Tween instance.
|
|
9
33
|
*/
|
|
10
|
-
constructor(parent) {
|
|
34
|
+
constructor(parent: import('./tween.js').Tween) {
|
|
11
35
|
this.parent = parent;
|
|
12
36
|
this.game = parent.game;
|
|
13
37
|
this.vStart = {};
|
|
@@ -44,7 +68,7 @@ export class TweenData {
|
|
|
44
68
|
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
45
69
|
* @returns {TweenData} This TweenData object for chaining.
|
|
46
70
|
*/
|
|
47
|
-
to(properties, duration, ease, delay, repeat, yoyo) {
|
|
71
|
+
to(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
48
72
|
this.vEnd = properties;
|
|
49
73
|
this.duration = duration;
|
|
50
74
|
this.easingFunction = ease;
|
|
@@ -65,7 +89,7 @@ export class TweenData {
|
|
|
65
89
|
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
66
90
|
* @returns {TweenData} This TweenData object for chaining.
|
|
67
91
|
*/
|
|
68
|
-
from(properties, duration, ease, delay, repeat, yoyo) {
|
|
92
|
+
from(properties: any, duration: number, ease: any, delay: number, repeat: number, yoyo: boolean) {
|
|
69
93
|
this.vEnd = properties;
|
|
70
94
|
this.duration = duration;
|
|
71
95
|
this.easingFunction = ease;
|
|
@@ -150,7 +174,7 @@ export class TweenData {
|
|
|
150
174
|
* @param {number} time - The current time in milliseconds.
|
|
151
175
|
* @returns {number} The tween status (TWEEN_PENDING, TWEEN_RUNNING, or TWEEN_COMPLETE).
|
|
152
176
|
*/
|
|
153
|
-
update(time) {
|
|
177
|
+
update(time: number) {
|
|
154
178
|
if (!this.isRunning) {
|
|
155
179
|
if (time >= this.startTime) {
|
|
156
180
|
this.isRunning = true;
|
|
@@ -193,7 +217,7 @@ export class TweenData {
|
|
|
193
217
|
* @param {number} frameRate - The frame rate to generate data for.
|
|
194
218
|
* @returns {object[]} An array of tween data points.
|
|
195
219
|
*/
|
|
196
|
-
generateData(frameRate) {
|
|
220
|
+
generateData(frameRate: number) {
|
|
197
221
|
if (this.parent.reverse) {
|
|
198
222
|
this.dt = this.duration;
|
|
199
223
|
} else {
|
|
@@ -295,4 +319,4 @@ export class TweenData {
|
|
|
295
319
|
}
|
|
296
320
|
return TWEEN_LOOPED;
|
|
297
321
|
}
|
|
298
|
-
}
|
|
322
|
+
}
|