@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
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Frame } from './frame.js';
|
|
2
2
|
import { cloneFrameData } from './frame_util.js';
|
|
3
3
|
|
|
4
4
|
export class FrameData {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
5
|
+
_frames: Frame[];
|
|
6
|
+
_frameNames: Record<string, number>;
|
|
7
|
+
|
|
9
8
|
constructor() {
|
|
10
|
-
/**
|
|
11
|
-
* @type {import('./frame.js').Frame[]}
|
|
12
|
-
*/
|
|
13
9
|
this._frames = [];
|
|
14
|
-
|
|
15
|
-
* @type {string[]}
|
|
16
|
-
*/
|
|
17
|
-
this._frameNames = [];
|
|
10
|
+
this._frameNames = {};
|
|
18
11
|
}
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
* Add a frame to the frame data collection.
|
|
22
|
-
* @param {import('./frame.js').Frame} frame - The frame to add.
|
|
23
|
-
* @returns {import('./frame.js').Frame} The added frame.
|
|
24
|
-
*/
|
|
25
|
-
addFrame(frame) {
|
|
13
|
+
addFrame(frame: Frame): Frame {
|
|
26
14
|
frame.index = this._frames.length;
|
|
27
15
|
this._frames.push(frame);
|
|
28
16
|
if (frame.name !== '') {
|
|
@@ -31,58 +19,32 @@ export class FrameData {
|
|
|
31
19
|
return frame;
|
|
32
20
|
}
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
* Get a frame by its index.
|
|
36
|
-
* @param {number} index - The index of the frame to get.
|
|
37
|
-
* @returns {import('./frame.js').Frame} The frame at the specified index, or the first frame if index is out of bounds.
|
|
38
|
-
*/
|
|
39
|
-
getFrame(index = 0) {
|
|
22
|
+
getFrame(index: number = 0): Frame {
|
|
40
23
|
if (index >= this._frames.length) {
|
|
41
24
|
index = 0;
|
|
42
25
|
}
|
|
43
26
|
return this._frames[index];
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
|
|
47
|
-
* Get a frame by its name.
|
|
48
|
-
* @param {string} name - The name of the frame to get.
|
|
49
|
-
* @returns {import('./frame.js').Frame} The frame with the specified name, or null if not found.
|
|
50
|
-
*/
|
|
51
|
-
getFrameByName(name) {
|
|
29
|
+
getFrameByName(name: string): Frame | null {
|
|
52
30
|
if (typeof this._frameNames[name] === 'number') {
|
|
53
31
|
return this._frames[this._frameNames[name]];
|
|
54
32
|
}
|
|
55
33
|
return null;
|
|
56
34
|
}
|
|
57
35
|
|
|
58
|
-
|
|
59
|
-
* Check if a frame with the given name exists.
|
|
60
|
-
* @param {string} name - The name of the frame to check.
|
|
61
|
-
* @returns {boolean} True if a frame with this name exists, false otherwise.
|
|
62
|
-
*/
|
|
63
|
-
checkFrameName(name) {
|
|
36
|
+
checkFrameName(name: string): boolean {
|
|
64
37
|
if (this._frameNames[name] == null) {
|
|
65
38
|
return false;
|
|
66
39
|
}
|
|
67
40
|
return true;
|
|
68
41
|
}
|
|
69
42
|
|
|
70
|
-
|
|
71
|
-
* Create a clone of this FrameData instance.
|
|
72
|
-
* @returns {FrameData} A new FrameData instance with cloned frames.
|
|
73
|
-
*/
|
|
74
|
-
clone() {
|
|
43
|
+
clone(): FrameData {
|
|
75
44
|
return cloneFrameData(this);
|
|
76
45
|
}
|
|
77
46
|
|
|
78
|
-
|
|
79
|
-
* Get a range of frames by index.
|
|
80
|
-
* @param {number} start - The starting index of the frame range.
|
|
81
|
-
* @param {number} end - The ending index of the frame range.
|
|
82
|
-
* @param {import('./frame.js').Frame[]} output - Optional array to populate with frames.
|
|
83
|
-
* @returns {import('./frame.js').Frame[]} An array of frames in the specified range.
|
|
84
|
-
*/
|
|
85
|
-
getFrameRange(start, end, output = null) {
|
|
47
|
+
getFrameRange(start: number, end: number, output: Frame[] | null = null): Frame[] {
|
|
86
48
|
const result = output || [];
|
|
87
49
|
for (let i = start; i <= end; i += 1) {
|
|
88
50
|
result.push(this._frames[i]);
|
|
@@ -90,21 +52,22 @@ export class FrameData {
|
|
|
90
52
|
return result;
|
|
91
53
|
}
|
|
92
54
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* @returns {number[]} An array of frame indexes.
|
|
99
|
-
*/
|
|
100
|
-
getFrameIndexes(frames, useNumericIndex = true, output = null) {
|
|
55
|
+
getFrameIndexes(
|
|
56
|
+
frames: (number | string)[],
|
|
57
|
+
useNumericIndex: boolean = true,
|
|
58
|
+
output: number[] | null = null
|
|
59
|
+
): number[] {
|
|
101
60
|
const result = output || [];
|
|
102
61
|
if (frames && frames.length > 0) {
|
|
103
62
|
for (let i = 0; i < frames.length; i += 1) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
63
|
+
const f = frames[i];
|
|
64
|
+
if (useNumericIndex && this._frames[f as number]) {
|
|
65
|
+
result.push(this._frames[f as number].index);
|
|
66
|
+
} else {
|
|
67
|
+
const found = this.getFrameByName(f as string);
|
|
68
|
+
if (found) {
|
|
69
|
+
result.push(found.index);
|
|
70
|
+
}
|
|
108
71
|
}
|
|
109
72
|
}
|
|
110
73
|
} else {
|
|
@@ -115,20 +78,12 @@ export class FrameData {
|
|
|
115
78
|
return result;
|
|
116
79
|
}
|
|
117
80
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*/
|
|
122
|
-
destroy() {
|
|
123
|
-
this._frames = null;
|
|
124
|
-
this._frameNames = null;
|
|
81
|
+
destroy(): void {
|
|
82
|
+
this._frames = null as unknown as Frame[];
|
|
83
|
+
this._frameNames = null as unknown as Record<string, number>;
|
|
125
84
|
}
|
|
126
85
|
|
|
127
|
-
|
|
128
|
-
* Get the total number of frames in this FrameData instance.
|
|
129
|
-
* @returns {number} The total number of frames.
|
|
130
|
-
*/
|
|
131
|
-
get total() {
|
|
86
|
+
get total(): number {
|
|
132
87
|
return this._frames.length;
|
|
133
88
|
}
|
|
134
|
-
}
|
|
89
|
+
}
|
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Frame } from './frame.js';
|
|
3
2
|
import { FrameData } from './frame_data.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
* Clone a Frame object.
|
|
7
|
-
* @param {Frame} frame - The frame to clone.
|
|
8
|
-
* @param {Frame} output - Optional output frame to populate.
|
|
9
|
-
* @returns {Frame} The cloned frame or the provided output frame.
|
|
10
|
-
*/
|
|
11
|
-
export const cloneFrame = (frame, output = null) => {
|
|
4
|
+
export const cloneFrame = (frame: Frame, output: Frame | null = null): Frame => {
|
|
12
5
|
const result = output || new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
13
6
|
result.initialize(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
14
7
|
return result;
|
|
15
8
|
};
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
* Clone a FrameData object.
|
|
19
|
-
* @param {FrameData} frameData - The frame data to clone.
|
|
20
|
-
* @param {FrameData} output - Optional output frame data to populate.
|
|
21
|
-
* @returns {FrameData} The cloned frame data or the provided output frame data.
|
|
22
|
-
*/
|
|
23
|
-
export const cloneFrameData = (frameData, output = null) => {
|
|
10
|
+
export const cloneFrameData = (frameData: FrameData, output: FrameData | null = null): FrameData => {
|
|
24
11
|
const result = output || new FrameData();
|
|
25
12
|
for (let i = 0; i < frameData.total; i += 1) {
|
|
26
13
|
result.addFrame(frameData.getFrame(i).clone());
|
|
27
14
|
}
|
|
28
15
|
return result;
|
|
29
|
-
};
|
|
16
|
+
};
|
package/src/phaser/core/game.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Logger } from '@vpmedia/simplify';
|
|
3
2
|
import { CanvasRenderer } from '../display/canvas/renderer.js';
|
|
4
3
|
import { addToDOM, create, removeFromDOM, setTouchAction } from '../display/canvas/util.js';
|
|
@@ -21,6 +20,36 @@ import { TweenManager } from './tween_manager.js';
|
|
|
21
20
|
import { World } from './world.js';
|
|
22
21
|
|
|
23
22
|
export class Game {
|
|
23
|
+
config!: any;
|
|
24
|
+
id!: number;
|
|
25
|
+
parent!: string | HTMLElement;
|
|
26
|
+
width!: number;
|
|
27
|
+
height!: number;
|
|
28
|
+
renderer!: CanvasRenderer | WebGLRenderer;
|
|
29
|
+
state!: SceneManager;
|
|
30
|
+
isBooted!: boolean;
|
|
31
|
+
paused!: boolean;
|
|
32
|
+
raf!: RequestAnimationFrame;
|
|
33
|
+
add!: GameObjectFactory;
|
|
34
|
+
cache!: Cache;
|
|
35
|
+
input!: Input;
|
|
36
|
+
load!: Loader;
|
|
37
|
+
scale!: ScaleManager;
|
|
38
|
+
sound!: SoundManager;
|
|
39
|
+
stage!: Stage;
|
|
40
|
+
time!: Time;
|
|
41
|
+
tweens!: TweenManager;
|
|
42
|
+
world!: World;
|
|
43
|
+
device!: Device;
|
|
44
|
+
logger!: Logger;
|
|
45
|
+
canvas!: HTMLCanvasElement;
|
|
46
|
+
context!: CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext;
|
|
47
|
+
onPause!: Signal;
|
|
48
|
+
onResume!: Signal;
|
|
49
|
+
onBoot!: Signal;
|
|
50
|
+
isPaused!: boolean;
|
|
51
|
+
contextLostBinded!: any;
|
|
52
|
+
contextRestoredBinded!: any;
|
|
24
53
|
/**
|
|
25
54
|
* Creates a new Game instance.
|
|
26
55
|
* @param {object} gameConfig - The configuration object for the game.
|
|
@@ -41,7 +70,7 @@ export class Game {
|
|
|
41
70
|
* @param {string|HTMLElement} gameConfig.parent - The parent element to append the canvas to.
|
|
42
71
|
* @param {object} gameConfig.state - The initial state object or class.
|
|
43
72
|
*/
|
|
44
|
-
constructor(gameConfig = {}) {
|
|
73
|
+
constructor(gameConfig: any = {}) {
|
|
45
74
|
if (!window.PhaserRegistry) {
|
|
46
75
|
window.PhaserRegistry = {};
|
|
47
76
|
}
|
|
@@ -206,7 +235,7 @@ export class Game {
|
|
|
206
235
|
* @param {string} key - The configuration key to parse.
|
|
207
236
|
* @param {*} defaultValue - The default value if the key is not found in config.
|
|
208
237
|
*/
|
|
209
|
-
parseConfigElement(config, key, defaultValue) {
|
|
238
|
+
parseConfigElement(config: any, key: string, defaultValue?: any) {
|
|
210
239
|
if (config[key] !== undefined) {
|
|
211
240
|
this.config[key] = config[key];
|
|
212
241
|
} else {
|
|
@@ -218,14 +247,14 @@ export class Game {
|
|
|
218
247
|
* Parses the configuration object and sets up game properties.
|
|
219
248
|
* @param {object} config - The configuration object to parse.
|
|
220
249
|
*/
|
|
221
|
-
parseConfig(config) {
|
|
250
|
+
parseConfig(config: any) {
|
|
222
251
|
this.logger = config.logger ?? new Logger('phaser');
|
|
223
252
|
this.logger.info('parseConfig');
|
|
224
253
|
this.parseConfigElement(config, 'width', 800);
|
|
225
254
|
this.parseConfigElement(config, 'height', 600);
|
|
226
|
-
this.parseConfigElement(config, 'backgroundColor',
|
|
255
|
+
this.parseConfigElement(config, 'backgroundColor', 0x00_00_00);
|
|
227
256
|
this.parseConfigElement(config, 'canvasID', '');
|
|
228
|
-
this.parseConfigElement(config, 'canvasStyle'
|
|
257
|
+
this.parseConfigElement(config, 'canvasStyle');
|
|
229
258
|
this.parseConfigElement(config, 'resolution', 1);
|
|
230
259
|
this.parseConfigElement(config, 'transparent', false);
|
|
231
260
|
this.parseConfigElement(config, 'antialias', false);
|
|
@@ -240,7 +269,7 @@ export class Game {
|
|
|
240
269
|
}
|
|
241
270
|
let state = null;
|
|
242
271
|
if (config.state) {
|
|
243
|
-
state = config
|
|
272
|
+
({ state } = config);
|
|
244
273
|
}
|
|
245
274
|
this.state = new SceneManager(this, state);
|
|
246
275
|
}
|
|
@@ -249,7 +278,7 @@ export class Game {
|
|
|
249
278
|
* Called when the WebGL context is lost.
|
|
250
279
|
* @param {WebGLContextEvent | Event} event - The WebGL context loss event.
|
|
251
280
|
*/
|
|
252
|
-
contextLost(event) {
|
|
281
|
+
contextLost(event: any) {
|
|
253
282
|
this.logger.info('contextLost', event);
|
|
254
283
|
event.preventDefault();
|
|
255
284
|
if (this.renderer) {
|
|
@@ -261,11 +290,11 @@ export class Game {
|
|
|
261
290
|
* Called when the WebGL context is restored.
|
|
262
291
|
* @param {WebGLContextEvent | Event} event - The WebGL context restore event.
|
|
263
292
|
*/
|
|
264
|
-
contextRestored(event) {
|
|
293
|
+
contextRestored(event: any) {
|
|
265
294
|
this.logger.info('contextRestored', event);
|
|
266
295
|
if (this.renderer) {
|
|
267
296
|
this.renderer.initContext(this);
|
|
268
|
-
//
|
|
297
|
+
// This.cache.clearGLTextures();
|
|
269
298
|
this.renderer.contextLost = false;
|
|
270
299
|
}
|
|
271
300
|
}
|
|
@@ -274,7 +303,7 @@ export class Game {
|
|
|
274
303
|
* Updates the game state.
|
|
275
304
|
* @param {number} time - The current timestamp.
|
|
276
305
|
*/
|
|
277
|
-
update(time) {
|
|
306
|
+
update(time: number) {
|
|
278
307
|
this.time.update(time);
|
|
279
308
|
if (!this.isPaused) {
|
|
280
309
|
this.scale.preUpdate();
|
package/src/phaser/core/input.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { create, remove } from '../display/canvas/pool.js';
|
|
3
2
|
import { Graphics } from '../display/graphics.js';
|
|
4
3
|
import { Image } from '../display/image.js';
|
|
@@ -15,11 +14,63 @@ import { Signal } from './signal.js';
|
|
|
15
14
|
const MAX_POINTERS = 10;
|
|
16
15
|
|
|
17
16
|
export class Input {
|
|
17
|
+
game!: any;
|
|
18
|
+
hitCanvas!: any;
|
|
19
|
+
hitContext!: any;
|
|
20
|
+
moveCallbacks!: any;
|
|
21
|
+
lockCallbacks!: any;
|
|
22
|
+
customCandidateHandler!: any;
|
|
23
|
+
customCandidateHandlerContext!: any;
|
|
24
|
+
pollRate!: any;
|
|
25
|
+
enabled!: any;
|
|
26
|
+
multiInputOverride!: any;
|
|
27
|
+
position!: any;
|
|
28
|
+
speed!: any;
|
|
29
|
+
circle!: any;
|
|
30
|
+
scale!: any;
|
|
31
|
+
maxPointers!: any;
|
|
32
|
+
tapRate!: any;
|
|
33
|
+
doubleTapRate!: any;
|
|
34
|
+
holdRate!: any;
|
|
35
|
+
justPressedRate!: any;
|
|
36
|
+
justReleasedRate!: any;
|
|
37
|
+
recordPointerHistory!: any;
|
|
38
|
+
recordRate!: any;
|
|
39
|
+
recordLimit!: any;
|
|
40
|
+
pointer1!: any;
|
|
41
|
+
pointer2!: any;
|
|
42
|
+
pointer3!: any;
|
|
43
|
+
pointer4!: any;
|
|
44
|
+
pointer5!: any;
|
|
45
|
+
pointer6!: any;
|
|
46
|
+
pointer7!: any;
|
|
47
|
+
pointer8!: any;
|
|
48
|
+
pointer9!: any;
|
|
49
|
+
pointer10!: any;
|
|
50
|
+
pointers!: any;
|
|
51
|
+
activePointer!: any;
|
|
52
|
+
mousePointer!: any;
|
|
53
|
+
mouse!: any;
|
|
54
|
+
touch!: any;
|
|
55
|
+
mspointer!: any;
|
|
56
|
+
resetLocked!: any;
|
|
57
|
+
onDown!: any;
|
|
58
|
+
onUp!: any;
|
|
59
|
+
onTap!: any;
|
|
60
|
+
onHold!: any;
|
|
61
|
+
minPriorityID!: any;
|
|
62
|
+
interactiveItems!: any;
|
|
63
|
+
_localPoint!: any;
|
|
64
|
+
_pollCounter!: any;
|
|
65
|
+
_oldPosition!: any;
|
|
66
|
+
_onClickTrampoline!: any;
|
|
67
|
+
_x!: any;
|
|
68
|
+
_y!: any;
|
|
18
69
|
/**
|
|
19
70
|
* TBD.
|
|
20
71
|
* @param {import('./game.js').Game} game - TBD.
|
|
21
72
|
*/
|
|
22
|
-
constructor(game) {
|
|
73
|
+
constructor(game: import('./game.js').Game) {
|
|
23
74
|
this.game = game;
|
|
24
75
|
this.hitCanvas = null;
|
|
25
76
|
this.hitContext = null;
|
|
@@ -103,7 +154,7 @@ export class Input {
|
|
|
103
154
|
}
|
|
104
155
|
this.mousePointer.active = true;
|
|
105
156
|
const scope = this;
|
|
106
|
-
this._onClickTrampoline = (event) => scope.onClickTrampoline(event);
|
|
157
|
+
this._onClickTrampoline = (event: any) => (scope as any).onClickTrampoline(event);
|
|
107
158
|
this.game.canvas.addEventListener('click', this._onClickTrampoline, false);
|
|
108
159
|
}
|
|
109
160
|
|
|
@@ -127,7 +178,7 @@ export class Input {
|
|
|
127
178
|
* @param {Function} callback - TBD.
|
|
128
179
|
* @param {object} context - TBD.
|
|
129
180
|
*/
|
|
130
|
-
setInteractiveCandidateHandler(callback, context) {
|
|
181
|
+
setInteractiveCandidateHandler(callback: Function, context: any) {
|
|
131
182
|
this.customCandidateHandler = callback;
|
|
132
183
|
this.customCandidateHandlerContext = context;
|
|
133
184
|
}
|
|
@@ -137,7 +188,7 @@ export class Input {
|
|
|
137
188
|
* @param {Function} callback - TBD.
|
|
138
189
|
* @param {object} context - TBD.
|
|
139
190
|
*/
|
|
140
|
-
addMoveCallback(callback, context) {
|
|
191
|
+
addMoveCallback(callback: Function, context: any) {
|
|
141
192
|
this.moveCallbacks.push({ callback, context });
|
|
142
193
|
}
|
|
143
194
|
|
|
@@ -146,7 +197,7 @@ export class Input {
|
|
|
146
197
|
* @param {Function} callback - TBD.
|
|
147
198
|
* @param {object} context - TBD.
|
|
148
199
|
*/
|
|
149
|
-
deleteMoveCallback(callback, context) {
|
|
200
|
+
deleteMoveCallback(callback: Function, context: any) {
|
|
150
201
|
let i = this.moveCallbacks.length;
|
|
151
202
|
while (i) {
|
|
152
203
|
i -= 1;
|
|
@@ -195,7 +246,7 @@ export class Input {
|
|
|
195
246
|
* TBD.
|
|
196
247
|
* @param {boolean} hard - TBD.
|
|
197
248
|
*/
|
|
198
|
-
reset(hard = false) {
|
|
249
|
+
reset(hard: boolean = false) {
|
|
199
250
|
if (!this.game.isBooted || this.resetLocked) {
|
|
200
251
|
return;
|
|
201
252
|
}
|
|
@@ -225,7 +276,7 @@ export class Input {
|
|
|
225
276
|
* @param {number} x - TBD.
|
|
226
277
|
* @param {number} y - TBD.
|
|
227
278
|
*/
|
|
228
|
-
resetSpeed(x, y) {
|
|
279
|
+
resetSpeed(x: number, y: number) {
|
|
229
280
|
this._oldPosition.setTo(x, y);
|
|
230
281
|
this.speed.setTo(0, 0);
|
|
231
282
|
}
|
|
@@ -235,7 +286,7 @@ export class Input {
|
|
|
235
286
|
* @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
|
|
236
287
|
* @returns {Pointer} TBD.
|
|
237
288
|
*/
|
|
238
|
-
startPointer(event) {
|
|
289
|
+
startPointer(event: any|TouchEvent|PointerEvent) {
|
|
239
290
|
if (this.maxPointers >= 0 && this.countActivePointers(this.maxPointers) >= this.maxPointers) {
|
|
240
291
|
return null;
|
|
241
292
|
}
|
|
@@ -259,7 +310,7 @@ export class Input {
|
|
|
259
310
|
* @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
|
|
260
311
|
* @returns {Pointer} TBD.
|
|
261
312
|
*/
|
|
262
|
-
updatePointer(event) {
|
|
313
|
+
updatePointer(event: any|TouchEvent|PointerEvent) {
|
|
263
314
|
if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
|
|
264
315
|
return this.pointer1.move(event);
|
|
265
316
|
}
|
|
@@ -280,7 +331,7 @@ export class Input {
|
|
|
280
331
|
* @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
|
|
281
332
|
* @returns {Pointer} TBD.
|
|
282
333
|
*/
|
|
283
|
-
stopPointer(event) {
|
|
334
|
+
stopPointer(event: any|TouchEvent|PointerEvent) {
|
|
284
335
|
if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
|
|
285
336
|
return this.pointer1.stop(event);
|
|
286
337
|
}
|
|
@@ -301,7 +352,7 @@ export class Input {
|
|
|
301
352
|
* @param {number} limit - TBD.
|
|
302
353
|
* @returns {number} TBD.
|
|
303
354
|
*/
|
|
304
|
-
countActivePointers(limit = this.pointers.length) {
|
|
355
|
+
countActivePointers(limit: number = this.pointers.length) {
|
|
305
356
|
let count = limit;
|
|
306
357
|
for (let i = 0; i < this.pointers.length && count > 0; i += 1) {
|
|
307
358
|
const pointer = this.pointers[i];
|
|
@@ -317,7 +368,7 @@ export class Input {
|
|
|
317
368
|
* @param {boolean} isActive - TBD.
|
|
318
369
|
* @returns {Pointer} TBD.
|
|
319
370
|
*/
|
|
320
|
-
getPointer(isActive = false) {
|
|
371
|
+
getPointer(isActive: boolean = false) {
|
|
321
372
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
322
373
|
const pointer = this.pointers[i];
|
|
323
374
|
if (pointer.active === isActive) {
|
|
@@ -332,7 +383,7 @@ export class Input {
|
|
|
332
383
|
* @param {number} identifier - TBD.
|
|
333
384
|
* @returns {Pointer} TBD.
|
|
334
385
|
*/
|
|
335
|
-
getPointerFromIdentifier(identifier) {
|
|
386
|
+
getPointerFromIdentifier(identifier: number) {
|
|
336
387
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
337
388
|
const pointer = this.pointers[i];
|
|
338
389
|
if (pointer.identifier === identifier) {
|
|
@@ -348,7 +399,7 @@ export class Input {
|
|
|
348
399
|
* @param {number} pointerId - TBD.
|
|
349
400
|
* @returns {Pointer} TBD.
|
|
350
401
|
*/
|
|
351
|
-
getPointerFromId(pointerId) {
|
|
402
|
+
getPointerFromId(pointerId: number) {
|
|
352
403
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
353
404
|
const pointer = this.pointers[i];
|
|
354
405
|
if (pointer.pointerId === pointerId) {
|
|
@@ -366,7 +417,7 @@ export class Input {
|
|
|
366
417
|
* @param {Point} output - TBD.
|
|
367
418
|
* @returns {Point} TBD.
|
|
368
419
|
*/
|
|
369
|
-
getLocalPosition(displayObject, pointer, output = null) {
|
|
420
|
+
getLocalPosition(displayObject: import('../display/display_object.js').DisplayObject, pointer: Pointer, output: Point = null) {
|
|
370
421
|
const result = output || new Point();
|
|
371
422
|
const wt = displayObject.worldTransform;
|
|
372
423
|
const id = 1 / (wt.a * wt.d + wt.c * -wt.b);
|
|
@@ -383,7 +434,7 @@ export class Input {
|
|
|
383
434
|
* @param {Point} localPoint - TBD.
|
|
384
435
|
* @returns {boolean} TBD.
|
|
385
436
|
*/
|
|
386
|
-
hitTest(displayObject, pointer, localPoint) {
|
|
437
|
+
hitTest(displayObject: import('../display/display_object.js').DisplayObject, pointer: Pointer, localPoint: Point) {
|
|
387
438
|
if (!displayObject.worldVisible) {
|
|
388
439
|
return false;
|
|
389
440
|
}
|