@vpmedia/phaser 1.115.0 → 1.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +56 -96
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +15 -14
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +10 -9
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +20 -20
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +11 -13
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +19 -8
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +38 -13
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +2 -2
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +24 -22
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +26 -26
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +2 -2
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +9 -7
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +12 -10
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +18 -33
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -4
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +10 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +20 -20
- package/src/phaser/core/animation_manager.ts +27 -24
- package/src/phaser/core/animation_parser.ts +2 -2
- package/src/phaser/core/array_set.ts +7 -7
- package/src/phaser/core/cache.ts +55 -51
- package/src/phaser/core/callback_context.test.ts +70 -0
- package/src/phaser/core/device_util.ts +13 -13
- package/src/phaser/core/dom.ts +26 -22
- package/src/phaser/core/factory.ts +6 -6
- package/src/phaser/core/game.ts +10 -10
- package/src/phaser/core/input.ts +37 -39
- package/src/phaser/core/input_handler.ts +90 -93
- package/src/phaser/core/input_mouse.ts +19 -19
- package/src/phaser/core/input_mspointer.ts +15 -15
- package/src/phaser/core/input_pointer.ts +37 -28
- package/src/phaser/core/input_touch.ts +17 -17
- package/src/phaser/core/loader.ts +52 -52
- package/src/phaser/core/loader_parser.ts +3 -3
- package/src/phaser/core/raf.ts +3 -3
- package/src/phaser/core/scale_manager.ts +86 -67
- package/src/phaser/core/scene.ts +7 -7
- package/src/phaser/core/scene_manager.ts +16 -16
- package/src/phaser/core/signal.ts +29 -19
- package/src/phaser/core/signal_binding.ts +4 -4
- package/src/phaser/core/sound.ts +17 -17
- package/src/phaser/core/sound_manager.ts +71 -72
- package/src/phaser/core/sound_sprite.ts +1 -1
- package/src/phaser/core/stage.ts +7 -7
- package/src/phaser/core/time.ts +16 -16
- package/src/phaser/core/timer.ts +36 -26
- package/src/phaser/core/tween.ts +23 -23
- package/src/phaser/core/tween_data.ts +41 -37
- package/src/phaser/core/tween_manager.ts +11 -11
- package/src/phaser/core/world.ts +1 -1
- package/src/phaser/display/bitmap_text.ts +13 -13
- package/src/phaser/display/button.ts +13 -13
- package/src/phaser/display/canvas/buffer.ts +3 -3
- package/src/phaser/display/canvas/graphics.ts +3 -3
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.ts +6 -6
- package/src/phaser/display/canvas/renderer.ts +6 -6
- package/src/phaser/display/canvas/tinter.ts +39 -8
- package/src/phaser/display/canvas/util.ts +15 -9
- package/src/phaser/display/display_object.ts +38 -38
- package/src/phaser/display/graphics.ts +30 -30
- package/src/phaser/display/graphics_data.ts +1 -1
- package/src/phaser/display/graphics_data_util.ts +1 -1
- package/src/phaser/display/group.ts +16 -16
- package/src/phaser/display/image.ts +30 -26
- package/src/phaser/display/sprite_util.ts +12 -4
- package/src/phaser/display/text.ts +55 -55
- package/src/phaser/display/webgl/abstract_filter.ts +1 -1
- package/src/phaser/display/webgl/base_texture.ts +22 -18
- package/src/phaser/display/webgl/blend_manager.ts +3 -3
- package/src/phaser/display/webgl/earcut.ts +3 -3
- package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
- package/src/phaser/display/webgl/filter_manager.ts +7 -7
- package/src/phaser/display/webgl/filter_texture.ts +3 -3
- package/src/phaser/display/webgl/graphics.ts +43 -41
- package/src/phaser/display/webgl/graphics_data.ts +2 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +6 -6
- package/src/phaser/display/webgl/renderer.ts +20 -25
- package/src/phaser/display/webgl/shader/normal.ts +3 -3
- package/src/phaser/display/webgl/shader_manager.ts +2 -2
- package/src/phaser/display/webgl/sprite_batch.ts +9 -9
- package/src/phaser/display/webgl/stencil_manager.ts +4 -4
- package/src/phaser/display/webgl/texture.ts +23 -42
- package/src/phaser/display/webgl/texture_util.ts +2 -2
- package/src/phaser/display/webgl/util.ts +11 -7
- package/src/phaser/geom/circle.ts +21 -21
- package/src/phaser/geom/ellipse.ts +7 -7
- package/src/phaser/geom/line.ts +29 -29
- package/src/phaser/geom/matrix.ts +13 -13
- package/src/phaser/geom/point.ts +36 -30
- package/src/phaser/geom/polygon.ts +6 -6
- package/src/phaser/geom/rectangle.ts +42 -42
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +13 -5
- package/src/phaser/geom/util/matrix.ts +3 -3
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +34 -17
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
package/src/phaser/core/dom.ts
CHANGED
|
@@ -6,7 +6,7 @@ class VisualBoundsDesktopRectangle {
|
|
|
6
6
|
* Gets the horizontal scroll position of the window.
|
|
7
7
|
* @returns {number} The horizontal scroll position in pixels.
|
|
8
8
|
*/
|
|
9
|
-
public get x() {
|
|
9
|
+
public get x(): number {
|
|
10
10
|
return globalThis && 'pageXOffset' in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ class VisualBoundsDesktopRectangle {
|
|
|
14
14
|
* Gets the vertical scroll position of the window.
|
|
15
15
|
* @returns {number} The vertical scroll position in pixels.
|
|
16
16
|
*/
|
|
17
|
-
public get y() {
|
|
17
|
+
public get y(): number {
|
|
18
18
|
return globalThis && 'pageYOffset' in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ class VisualBoundsDesktopRectangle {
|
|
|
22
22
|
* Gets the width of the window.
|
|
23
23
|
* @returns {number} The width of the window in pixels.
|
|
24
24
|
*/
|
|
25
|
-
public get width() {
|
|
25
|
+
public get width(): number {
|
|
26
26
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -30,7 +30,7 @@ class VisualBoundsDesktopRectangle {
|
|
|
30
30
|
* Gets the height of the window.
|
|
31
31
|
* @returns {number} The height of the window in pixels.
|
|
32
32
|
*/
|
|
33
|
-
public get height() {
|
|
33
|
+
public get height(): number {
|
|
34
34
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -52,7 +52,7 @@ class LayoutBoundsDesktopRectangle {
|
|
|
52
52
|
* Gets the width of the window.
|
|
53
53
|
* @returns {number} The width of the window in pixels.
|
|
54
54
|
*/
|
|
55
|
-
public get width() {
|
|
55
|
+
public get width(): number {
|
|
56
56
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ class LayoutBoundsDesktopRectangle {
|
|
|
60
60
|
* Gets the height of the window.
|
|
61
61
|
* @returns {number} The height of the window in pixels.
|
|
62
62
|
*/
|
|
63
|
-
public get height() {
|
|
63
|
+
public get height(): number {
|
|
64
64
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -70,7 +70,7 @@ class VisualBoundsRectangle {
|
|
|
70
70
|
* Gets the horizontal scroll position of the document.
|
|
71
71
|
* @returns {number} The horizontal scroll position in pixels.
|
|
72
72
|
*/
|
|
73
|
-
public get x() {
|
|
73
|
+
public get x(): number {
|
|
74
74
|
return globalThis && 'pageXOffset' in globalThis ? window.pageXOffset : document.documentElement.scrollLeft;
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -78,7 +78,7 @@ class VisualBoundsRectangle {
|
|
|
78
78
|
* Gets the vertical scroll position of the document.
|
|
79
79
|
* @returns {number} The vertical scroll position in pixels.
|
|
80
80
|
*/
|
|
81
|
-
public get y() {
|
|
81
|
+
public get y(): number {
|
|
82
82
|
return globalThis && 'pageYOffset' in globalThis ? window.pageYOffset : document.documentElement.scrollTop;
|
|
83
83
|
}
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ class VisualBoundsRectangle {
|
|
|
86
86
|
* TBD.
|
|
87
87
|
* @returns {number} TBD.
|
|
88
88
|
*/
|
|
89
|
-
public get width() {
|
|
89
|
+
public get width(): number {
|
|
90
90
|
return window.innerWidth;
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ class VisualBoundsRectangle {
|
|
|
94
94
|
* TBD.
|
|
95
95
|
* @returns {number} TBD.
|
|
96
96
|
*/
|
|
97
|
-
public get height() {
|
|
97
|
+
public get height(): number {
|
|
98
98
|
return window.innerHeight;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -116,7 +116,7 @@ class LayoutBoundsRectangle {
|
|
|
116
116
|
* TBD.
|
|
117
117
|
* @returns {number} TBD.
|
|
118
118
|
*/
|
|
119
|
-
public get width() {
|
|
119
|
+
public get width(): number {
|
|
120
120
|
const a = document.documentElement.clientWidth;
|
|
121
121
|
const b = window.innerWidth;
|
|
122
122
|
return a < b ? b : a; // max
|
|
@@ -126,7 +126,7 @@ class LayoutBoundsRectangle {
|
|
|
126
126
|
* TBD.
|
|
127
127
|
* @returns {number} TBD.
|
|
128
128
|
*/
|
|
129
|
-
public get height() {
|
|
129
|
+
public get height(): number {
|
|
130
130
|
const a = document.documentElement.clientHeight;
|
|
131
131
|
const b = window.innerHeight;
|
|
132
132
|
return a < b ? b : a; // max
|
|
@@ -153,7 +153,7 @@ class DocumentBoundsRectangle {
|
|
|
153
153
|
* TBD.
|
|
154
154
|
* @returns {number} TBD.
|
|
155
155
|
*/
|
|
156
|
-
public get width() {
|
|
156
|
+
public get width(): number {
|
|
157
157
|
const d = document.documentElement;
|
|
158
158
|
return Math.max(d.clientWidth, d.offsetWidth, d.scrollWidth);
|
|
159
159
|
}
|
|
@@ -162,7 +162,7 @@ class DocumentBoundsRectangle {
|
|
|
162
162
|
* TBD.
|
|
163
163
|
* @returns {number} TBD.
|
|
164
164
|
*/
|
|
165
|
-
public get height() {
|
|
165
|
+
public get height(): number {
|
|
166
166
|
const d = document.documentElement;
|
|
167
167
|
return Math.max(d.clientHeight, d.offsetHeight, d.scrollHeight);
|
|
168
168
|
}
|
|
@@ -189,9 +189,13 @@ export class DOM {
|
|
|
189
189
|
this.layoutBounds = this.treatAsDesktop ? new LayoutBoundsDesktopRectangle() : new LayoutBoundsRectangle();
|
|
190
190
|
this.documentBounds = new DocumentBoundsRectangle();
|
|
191
191
|
this.scrollXProvider =
|
|
192
|
-
globalThis && 'pageXOffset' in globalThis
|
|
192
|
+
globalThis && 'pageXOffset' in globalThis
|
|
193
|
+
? (): number => window.pageXOffset
|
|
194
|
+
: (): number => document.documentElement.scrollLeft;
|
|
193
195
|
this.scrollYProvider =
|
|
194
|
-
globalThis && 'pageYOffset' in globalThis
|
|
196
|
+
globalThis && 'pageYOffset' in globalThis
|
|
197
|
+
? (): number => window.pageYOffset
|
|
198
|
+
: (): number => document.documentElement.scrollTop;
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
/**
|
|
@@ -200,7 +204,7 @@ export class DOM {
|
|
|
200
204
|
* @param {Point} point - Optional Point object to store the result.
|
|
201
205
|
* @returns {Point} The offset position of the element.
|
|
202
206
|
*/
|
|
203
|
-
public getOffset(element: HTMLCanvasElement, point: Point | null = null) {
|
|
207
|
+
public getOffset(element: HTMLCanvasElement, point: Point | null = null): Point {
|
|
204
208
|
point = point ?? new Point();
|
|
205
209
|
const box = element.getBoundingClientRect();
|
|
206
210
|
const scrollTop = this.scrollY;
|
|
@@ -251,7 +255,7 @@ export class DOM {
|
|
|
251
255
|
* @param {string} primaryFallback - The fallback method to use if screen orientation API is not available.
|
|
252
256
|
* @returns {string} The screen orientation ('portrait-primary', 'landscape-primary', etc.).
|
|
253
257
|
*/
|
|
254
|
-
public getScreenOrientation(primaryFallback: string | null = null) {
|
|
258
|
+
public getScreenOrientation(primaryFallback: string | null = null): OrientationType {
|
|
255
259
|
const { screen } = globalThis;
|
|
256
260
|
// @ts-expect-error
|
|
257
261
|
const orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
|
|
@@ -285,7 +289,7 @@ export class DOM {
|
|
|
285
289
|
* Gets the horizontal scroll position of the window.
|
|
286
290
|
* @returns {number} The horizontal scroll position in pixels.
|
|
287
291
|
*/
|
|
288
|
-
public get scrollX() {
|
|
292
|
+
public get scrollX(): number {
|
|
289
293
|
return this.scrollXProvider();
|
|
290
294
|
}
|
|
291
295
|
|
|
@@ -293,7 +297,7 @@ export class DOM {
|
|
|
293
297
|
* Gets the vertical scroll position of the window.
|
|
294
298
|
* @returns {number} The vertical scroll position in pixels.
|
|
295
299
|
*/
|
|
296
|
-
public get scrollY() {
|
|
300
|
+
public get scrollY(): number {
|
|
297
301
|
return this.scrollYProvider();
|
|
298
302
|
}
|
|
299
303
|
|
|
@@ -301,7 +305,7 @@ export class DOM {
|
|
|
301
305
|
* Gets the width of the window's client area.
|
|
302
306
|
* @returns {number} The width of the client area in pixels.
|
|
303
307
|
*/
|
|
304
|
-
public get clientWidth() {
|
|
308
|
+
public get clientWidth(): number {
|
|
305
309
|
return Math.max(window.innerWidth, document.documentElement.clientWidth);
|
|
306
310
|
}
|
|
307
311
|
|
|
@@ -309,7 +313,7 @@ export class DOM {
|
|
|
309
313
|
* Gets the height of the window's client area.
|
|
310
314
|
* @returns {number} The height of the client area in pixels.
|
|
311
315
|
*/
|
|
312
|
-
public get clientHeight() {
|
|
316
|
+
public get clientHeight(): number {
|
|
313
317
|
return Math.max(window.innerHeight, document.documentElement.clientHeight);
|
|
314
318
|
}
|
|
315
319
|
}
|
|
@@ -25,7 +25,7 @@ export class GameObjectFactory {
|
|
|
25
25
|
* @param {Group} group - The parent group for the image.
|
|
26
26
|
* @returns {Image} The created Image object.
|
|
27
27
|
*/
|
|
28
|
-
public image(x: number, y: number, key: string, frame: any, group: Group | null = null) {
|
|
28
|
+
public image(x: number, y: number, key: string, frame: any, group: Group | null = null): Image {
|
|
29
29
|
const target = group ?? this.game.world;
|
|
30
30
|
return target.add(new Image(this.game, x, y, key, frame));
|
|
31
31
|
}
|
|
@@ -37,7 +37,7 @@ export class GameObjectFactory {
|
|
|
37
37
|
* @param {boolean} addToStage - Whether to add the group to the stage.
|
|
38
38
|
* @returns {Group} The created Group object.
|
|
39
39
|
*/
|
|
40
|
-
public group(parent: Group | null = null, name: string | null = null, addToStage = false) {
|
|
40
|
+
public group(parent: Group | null = null, name: string | null = null, addToStage = false): Group {
|
|
41
41
|
return new Group(this.game, parent, name, addToStage);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -50,7 +50,7 @@ export class GameObjectFactory {
|
|
|
50
50
|
* @param {Group | null} group - The parent group for the text.
|
|
51
51
|
* @returns {Text} The created Text object.
|
|
52
52
|
*/
|
|
53
|
-
public text(x: number, y: number, text: any, style: any, group: Group | null = null) {
|
|
53
|
+
public text(x: number, y: number, text: any, style: any, group: Group | null = null): Text {
|
|
54
54
|
const parent = group ?? this.game.world;
|
|
55
55
|
return parent.add(new Text(this.game, x, y, text, style));
|
|
56
56
|
}
|
|
@@ -80,7 +80,7 @@ export class GameObjectFactory {
|
|
|
80
80
|
downFrame: string | null = null,
|
|
81
81
|
upFrame: string | null = null,
|
|
82
82
|
group: Group | null = null
|
|
83
|
-
) {
|
|
83
|
+
): Button {
|
|
84
84
|
const parent = group ?? this.game.world;
|
|
85
85
|
return parent.add(
|
|
86
86
|
new Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame)
|
|
@@ -94,7 +94,7 @@ export class GameObjectFactory {
|
|
|
94
94
|
* @param {Group | null} group - The parent group for the graphics object.
|
|
95
95
|
* @returns {Graphics} The created Graphics object.
|
|
96
96
|
*/
|
|
97
|
-
public graphics(x = 0, y = 0, group: Group | null = null) {
|
|
97
|
+
public graphics(x = 0, y = 0, group: Group | null = null): Graphics {
|
|
98
98
|
const parent = group ?? this.game.world;
|
|
99
99
|
return parent.add(new Graphics(this.game, x, y));
|
|
100
100
|
}
|
|
@@ -118,7 +118,7 @@ export class GameObjectFactory {
|
|
|
118
118
|
size: number,
|
|
119
119
|
group: Group | null = null,
|
|
120
120
|
align = 'left'
|
|
121
|
-
) {
|
|
121
|
+
): BitmapText {
|
|
122
122
|
const parent = group ?? this.game.world;
|
|
123
123
|
return parent.add(new BitmapText(this.game, x, y, font, text, size, align));
|
|
124
124
|
}
|
package/src/phaser/core/game.ts
CHANGED
|
@@ -101,7 +101,7 @@ export class Game {
|
|
|
101
101
|
} else {
|
|
102
102
|
window.addEventListener(
|
|
103
103
|
'load',
|
|
104
|
-
() => {
|
|
104
|
+
(): void => {
|
|
105
105
|
initialize(this.device);
|
|
106
106
|
this.boot();
|
|
107
107
|
},
|
|
@@ -113,7 +113,7 @@ export class Game {
|
|
|
113
113
|
/**
|
|
114
114
|
* Boots the game and initializes all systems.
|
|
115
115
|
*/
|
|
116
|
-
public boot() {
|
|
116
|
+
public boot(): void {
|
|
117
117
|
if (this.isBooted) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -149,7 +149,7 @@ export class Game {
|
|
|
149
149
|
/**
|
|
150
150
|
* Creates the renderer canvas element.
|
|
151
151
|
*/
|
|
152
|
-
public createRendererCanvas() {
|
|
152
|
+
public createRendererCanvas(): void {
|
|
153
153
|
this.logger.info('createRendererCanvas');
|
|
154
154
|
if (this.canvas) {
|
|
155
155
|
removeFromDOM(this.canvas);
|
|
@@ -172,7 +172,7 @@ export class Game {
|
|
|
172
172
|
/**
|
|
173
173
|
* Initializes the renderer and sets up the rendering context.
|
|
174
174
|
*/
|
|
175
|
-
public initRenderer() {
|
|
175
|
+
public initRenderer(): void {
|
|
176
176
|
let isWebGlReady = false;
|
|
177
177
|
if (this.config.renderType === RENDER_AUTO || this.config.renderType === RENDER_WEBGL) {
|
|
178
178
|
try {
|
|
@@ -223,7 +223,7 @@ export class Game {
|
|
|
223
223
|
* @param {string} key - The configuration key to parse.
|
|
224
224
|
* @param {*} defaultValue - The default value if the key is not found in config.
|
|
225
225
|
*/
|
|
226
|
-
public parseConfigElement(config: any, key: string, defaultValue?: any) {
|
|
226
|
+
public parseConfigElement(config: any, key: string, defaultValue?: any): void {
|
|
227
227
|
if (config[key] !== undefined) {
|
|
228
228
|
this.config[key] = config[key];
|
|
229
229
|
} else {
|
|
@@ -235,7 +235,7 @@ export class Game {
|
|
|
235
235
|
* Parses the configuration object and sets up game properties.
|
|
236
236
|
* @param {object} config - The configuration object to parse.
|
|
237
237
|
*/
|
|
238
|
-
public parseConfig(config: any) {
|
|
238
|
+
public parseConfig(config: any): void {
|
|
239
239
|
this.logger = config.logger ?? getLogger(['phaser']);
|
|
240
240
|
this.logger.info('parseConfig');
|
|
241
241
|
this.parseConfigElement(config, 'width', 800);
|
|
@@ -266,7 +266,7 @@ export class Game {
|
|
|
266
266
|
* Called when the WebGL context is lost.
|
|
267
267
|
* @param {WebGLContextEvent | Event} event - The WebGL context loss event.
|
|
268
268
|
*/
|
|
269
|
-
public contextLost(event: any) {
|
|
269
|
+
public contextLost(event: any): void {
|
|
270
270
|
this.logger.info('contextLost', event);
|
|
271
271
|
event.preventDefault();
|
|
272
272
|
if (this.renderer) {
|
|
@@ -278,7 +278,7 @@ export class Game {
|
|
|
278
278
|
* Called when the WebGL context is restored.
|
|
279
279
|
* @param {WebGLContextEvent | Event} event - The WebGL context restore event.
|
|
280
280
|
*/
|
|
281
|
-
public contextRestored(event: any) {
|
|
281
|
+
public contextRestored(event: any): void {
|
|
282
282
|
this.logger.info('contextRestored', event);
|
|
283
283
|
if (this.renderer) {
|
|
284
284
|
this.renderer.initContext(this);
|
|
@@ -291,7 +291,7 @@ export class Game {
|
|
|
291
291
|
* Updates the game state.
|
|
292
292
|
* @param {number} time - The current timestamp.
|
|
293
293
|
*/
|
|
294
|
-
public update(time: number) {
|
|
294
|
+
public update(time: number): void {
|
|
295
295
|
this.time.update(time);
|
|
296
296
|
if (!this.isPaused) {
|
|
297
297
|
this.scale.preUpdate();
|
|
@@ -314,7 +314,7 @@ export class Game {
|
|
|
314
314
|
/**
|
|
315
315
|
* Destroys the game and cleans up all resources.
|
|
316
316
|
*/
|
|
317
|
-
public destroy() {
|
|
317
|
+
public destroy(): void {
|
|
318
318
|
this.logger.info('destroy');
|
|
319
319
|
this.isPaused = true;
|
|
320
320
|
|
package/src/phaser/core/input.ts
CHANGED
|
@@ -19,11 +19,11 @@ const MAX_POINTERS = 10;
|
|
|
19
19
|
export class Input {
|
|
20
20
|
public game!: Game;
|
|
21
21
|
public hitCanvas!: HTMLCanvasElement;
|
|
22
|
-
public hitContext!:
|
|
23
|
-
public moveCallbacks!: { callback: Function; context:
|
|
24
|
-
public lockCallbacks!:
|
|
25
|
-
public customCandidateHandler!:
|
|
26
|
-
public customCandidateHandlerContext!:
|
|
22
|
+
public hitContext!: CanvasRenderingContext2D | null;
|
|
23
|
+
public moveCallbacks!: { callback: Function; context: unknown }[];
|
|
24
|
+
public lockCallbacks!: unknown[];
|
|
25
|
+
public customCandidateHandler!: Function | null;
|
|
26
|
+
public customCandidateHandlerContext!: unknown;
|
|
27
27
|
public pollRate!: number;
|
|
28
28
|
public enabled!: boolean;
|
|
29
29
|
public multiInputOverride!: number;
|
|
@@ -40,15 +40,15 @@ export class Input {
|
|
|
40
40
|
public recordPointerHistory!: boolean;
|
|
41
41
|
public recordRate!: number;
|
|
42
42
|
public recordLimit!: number;
|
|
43
|
-
public pointer1!:
|
|
44
|
-
public pointer2!:
|
|
45
|
-
public pointer3!:
|
|
46
|
-
public pointer4!:
|
|
47
|
-
public pointer5!:
|
|
48
|
-
public pointer6!:
|
|
49
|
-
public pointer7!:
|
|
50
|
-
public pointer8!:
|
|
51
|
-
public pointer9!:
|
|
43
|
+
public pointer1!: Pointer;
|
|
44
|
+
public pointer2!: Pointer;
|
|
45
|
+
public pointer3!: Pointer | null;
|
|
46
|
+
public pointer4!: Pointer | null;
|
|
47
|
+
public pointer5!: Pointer | null;
|
|
48
|
+
public pointer6!: Pointer | null;
|
|
49
|
+
public pointer7!: Pointer | null;
|
|
50
|
+
public pointer8!: Pointer | null;
|
|
51
|
+
public pointer9!: Pointer | null;
|
|
52
52
|
public pointer10!: any;
|
|
53
53
|
public pointers!: Pointer[];
|
|
54
54
|
public activePointer!: Pointer;
|
|
@@ -97,8 +97,6 @@ export class Input {
|
|
|
97
97
|
this.recordPointerHistory = false;
|
|
98
98
|
this.recordRate = 100;
|
|
99
99
|
this.recordLimit = 100;
|
|
100
|
-
this.pointer1 = null;
|
|
101
|
-
this.pointer2 = null;
|
|
102
100
|
this.pointer3 = null;
|
|
103
101
|
this.pointer4 = null;
|
|
104
102
|
this.pointer5 = null;
|
|
@@ -130,7 +128,7 @@ export class Input {
|
|
|
130
128
|
/**
|
|
131
129
|
* TBD.
|
|
132
130
|
*/
|
|
133
|
-
public boot() {
|
|
131
|
+
public boot(): void {
|
|
134
132
|
this.mousePointer = new Pointer(this.game, 0, POINTER_CURSOR);
|
|
135
133
|
this.addPointer();
|
|
136
134
|
this.addPointer();
|
|
@@ -164,7 +162,7 @@ export class Input {
|
|
|
164
162
|
/**
|
|
165
163
|
* TBD.
|
|
166
164
|
*/
|
|
167
|
-
public destroy() {
|
|
165
|
+
public destroy(): void {
|
|
168
166
|
this.mouse.stop();
|
|
169
167
|
if (this.game.device.mspointer) {
|
|
170
168
|
this.mspointer.stop();
|
|
@@ -181,7 +179,7 @@ export class Input {
|
|
|
181
179
|
* @param {Function} callback - TBD.
|
|
182
180
|
* @param {object} context - TBD.
|
|
183
181
|
*/
|
|
184
|
-
public setInteractiveCandidateHandler(callback: Function, context:
|
|
182
|
+
public setInteractiveCandidateHandler(callback: Function, context: unknown): void {
|
|
185
183
|
this.customCandidateHandler = callback;
|
|
186
184
|
this.customCandidateHandlerContext = context;
|
|
187
185
|
}
|
|
@@ -191,7 +189,7 @@ export class Input {
|
|
|
191
189
|
* @param {Function} callback - TBD.
|
|
192
190
|
* @param {object} context - TBD.
|
|
193
191
|
*/
|
|
194
|
-
public addMoveCallback(callback: Function, context:
|
|
192
|
+
public addMoveCallback(callback: Function, context: unknown): void {
|
|
195
193
|
this.moveCallbacks.push({ callback, context });
|
|
196
194
|
}
|
|
197
195
|
|
|
@@ -200,7 +198,7 @@ export class Input {
|
|
|
200
198
|
* @param {Function} callback - TBD.
|
|
201
199
|
* @param {object} context - TBD.
|
|
202
200
|
*/
|
|
203
|
-
public deleteMoveCallback(callback: Function, context:
|
|
201
|
+
public deleteMoveCallback(callback: Function, context: unknown): void {
|
|
204
202
|
let i = this.moveCallbacks.length;
|
|
205
203
|
while (i) {
|
|
206
204
|
i -= 1;
|
|
@@ -215,7 +213,7 @@ export class Input {
|
|
|
215
213
|
* TBD.
|
|
216
214
|
* @returns {Pointer} TBD.
|
|
217
215
|
*/
|
|
218
|
-
public addPointer() {
|
|
216
|
+
public addPointer(): Pointer | null {
|
|
219
217
|
if (this.pointers.length >= MAX_POINTERS) {
|
|
220
218
|
this.game.logger.warn(`Input.addPointer: Maximum limit of ${MAX_POINTERS} pointers reached.`);
|
|
221
219
|
return null;
|
|
@@ -230,7 +228,7 @@ export class Input {
|
|
|
230
228
|
/**
|
|
231
229
|
* TBD.
|
|
232
230
|
*/
|
|
233
|
-
public update() {
|
|
231
|
+
public update(): void {
|
|
234
232
|
if (this.pollRate > 0 && this._pollCounter < this.pollRate) {
|
|
235
233
|
this._pollCounter += 1;
|
|
236
234
|
return;
|
|
@@ -249,7 +247,7 @@ export class Input {
|
|
|
249
247
|
* TBD.
|
|
250
248
|
* @param {boolean} hard - TBD.
|
|
251
249
|
*/
|
|
252
|
-
public reset(hard = false) {
|
|
250
|
+
public reset(hard = false): void {
|
|
253
251
|
if (!this.game.isBooted || this.resetLocked) {
|
|
254
252
|
return;
|
|
255
253
|
}
|
|
@@ -279,7 +277,7 @@ export class Input {
|
|
|
279
277
|
* @param {number} x - TBD.
|
|
280
278
|
* @param {number} y - TBD.
|
|
281
279
|
*/
|
|
282
|
-
public resetSpeed(x: number, y: number) {
|
|
280
|
+
public resetSpeed(x: number, y: number): void {
|
|
283
281
|
this._oldPosition.setTo(x, y);
|
|
284
282
|
this.speed.setTo(0, 0);
|
|
285
283
|
}
|
|
@@ -355,7 +353,7 @@ export class Input {
|
|
|
355
353
|
* @param {number} limit - TBD.
|
|
356
354
|
* @returns {number} TBD.
|
|
357
355
|
*/
|
|
358
|
-
public countActivePointers(limit: number = this.pointers.length) {
|
|
356
|
+
public countActivePointers(limit: number = this.pointers.length): number {
|
|
359
357
|
let count = limit;
|
|
360
358
|
for (let i = 0; i < this.pointers.length && count > 0; i += 1) {
|
|
361
359
|
const pointer = this.pointers[i]!;
|
|
@@ -371,7 +369,7 @@ export class Input {
|
|
|
371
369
|
* @param {boolean} isActive - TBD.
|
|
372
370
|
* @returns {Pointer} TBD.
|
|
373
371
|
*/
|
|
374
|
-
public getPointer(isActive = false) {
|
|
372
|
+
public getPointer(isActive = false): Pointer | null {
|
|
375
373
|
for (const pointer of this.pointers) {
|
|
376
374
|
if (pointer.active === isActive) {
|
|
377
375
|
return pointer;
|
|
@@ -385,7 +383,7 @@ export class Input {
|
|
|
385
383
|
* @param {number} identifier - TBD.
|
|
386
384
|
* @returns {Pointer} TBD.
|
|
387
385
|
*/
|
|
388
|
-
public getPointerFromIdentifier(identifier: number) {
|
|
386
|
+
public getPointerFromIdentifier(identifier: number): Pointer | null {
|
|
389
387
|
for (const pointer of this.pointers) {
|
|
390
388
|
if (pointer.identifier === identifier) {
|
|
391
389
|
return pointer;
|
|
@@ -400,7 +398,7 @@ export class Input {
|
|
|
400
398
|
* @param {number} pointerId - TBD.
|
|
401
399
|
* @returns {Pointer} TBD.
|
|
402
400
|
*/
|
|
403
|
-
public getPointerFromId(pointerId: number) {
|
|
401
|
+
public getPointerFromId(pointerId: number): Pointer | null {
|
|
404
402
|
for (const pointer of this.pointers) {
|
|
405
403
|
if (pointer.pointerId === pointerId) {
|
|
406
404
|
return pointer;
|
|
@@ -417,7 +415,7 @@ export class Input {
|
|
|
417
415
|
* @param {Point} output - TBD.
|
|
418
416
|
* @returns {Point} TBD.
|
|
419
417
|
*/
|
|
420
|
-
public getLocalPosition(displayObject: DisplayObject, pointer: Pointer, output: Point | null = null) {
|
|
418
|
+
public getLocalPosition(displayObject: DisplayObject, pointer: Pointer, output: Point | null = null): Point {
|
|
421
419
|
const result = output ?? new Point();
|
|
422
420
|
const wt = displayObject.worldTransform;
|
|
423
421
|
const id = 1 / (wt.a * wt.d + wt.c * -wt.b);
|
|
@@ -434,7 +432,7 @@ export class Input {
|
|
|
434
432
|
* @param {Point} localPoint - TBD.
|
|
435
433
|
* @returns {boolean} TBD.
|
|
436
434
|
*/
|
|
437
|
-
public hitTest(displayObject: DisplayObject, pointer: Pointer, localPoint: Point) {
|
|
435
|
+
public hitTest(displayObject: DisplayObject, pointer: Pointer, localPoint: Point): boolean {
|
|
438
436
|
if (!displayObject.worldVisible) {
|
|
439
437
|
return false;
|
|
440
438
|
}
|
|
@@ -472,7 +470,7 @@ export class Input {
|
|
|
472
470
|
/**
|
|
473
471
|
* TBD.
|
|
474
472
|
*/
|
|
475
|
-
public onClickTrampoline() {
|
|
473
|
+
public onClickTrampoline(): void {
|
|
476
474
|
this.activePointer.processClickTrampolines();
|
|
477
475
|
}
|
|
478
476
|
|
|
@@ -480,7 +478,7 @@ export class Input {
|
|
|
480
478
|
* TBD.
|
|
481
479
|
* @returns {number} TBD.
|
|
482
480
|
*/
|
|
483
|
-
public get x() {
|
|
481
|
+
public get x(): number {
|
|
484
482
|
return this._x;
|
|
485
483
|
}
|
|
486
484
|
|
|
@@ -495,7 +493,7 @@ export class Input {
|
|
|
495
493
|
* TBD.
|
|
496
494
|
* @returns {number} TBD.
|
|
497
495
|
*/
|
|
498
|
-
public get y() {
|
|
496
|
+
public get y(): number {
|
|
499
497
|
return this._y;
|
|
500
498
|
}
|
|
501
499
|
|
|
@@ -510,7 +508,7 @@ export class Input {
|
|
|
510
508
|
* TBD.
|
|
511
509
|
* @returns {boolean} TBD.
|
|
512
510
|
*/
|
|
513
|
-
public get pollLocked() {
|
|
511
|
+
public get pollLocked(): boolean {
|
|
514
512
|
return this.pollRate > 0 && this._pollCounter < this.pollRate;
|
|
515
513
|
}
|
|
516
514
|
|
|
@@ -518,7 +516,7 @@ export class Input {
|
|
|
518
516
|
* TBD.
|
|
519
517
|
* @returns {number} TBD.
|
|
520
518
|
*/
|
|
521
|
-
public get totalInactivePointers() {
|
|
519
|
+
public get totalInactivePointers(): number {
|
|
522
520
|
return this.pointers.length - this.countActivePointers();
|
|
523
521
|
}
|
|
524
522
|
|
|
@@ -526,7 +524,7 @@ export class Input {
|
|
|
526
524
|
* TBD.
|
|
527
525
|
* @returns {number} TBD.
|
|
528
526
|
*/
|
|
529
|
-
public get totalActivePointers() {
|
|
527
|
+
public get totalActivePointers(): number {
|
|
530
528
|
return this.countActivePointers();
|
|
531
529
|
}
|
|
532
530
|
|
|
@@ -534,7 +532,7 @@ export class Input {
|
|
|
534
532
|
* TBD.
|
|
535
533
|
* @returns {number} TBD.
|
|
536
534
|
*/
|
|
537
|
-
public get worldX() {
|
|
535
|
+
public get worldX(): number {
|
|
538
536
|
return this.x;
|
|
539
537
|
}
|
|
540
538
|
|
|
@@ -542,7 +540,7 @@ export class Input {
|
|
|
542
540
|
* TBD.
|
|
543
541
|
* @returns {number} TBD.
|
|
544
542
|
*/
|
|
545
|
-
public get worldY() {
|
|
543
|
+
public get worldY(): number {
|
|
546
544
|
return this.y;
|
|
547
545
|
}
|
|
548
546
|
}
|