@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
|
@@ -5,6 +5,21 @@ import type { Game } from './game.js';
|
|
|
5
5
|
import { DOM } from './dom.js';
|
|
6
6
|
import { Signal } from './signal.js';
|
|
7
7
|
|
|
8
|
+
/** The gap the canvas leaves around itself inside its parent. */
|
|
9
|
+
export type ScaleMargin = { left: number; top: number; right: number; bottom: number; x: number; y: number };
|
|
10
|
+
|
|
11
|
+
/** Which edges the layout is allowed to expand against. */
|
|
12
|
+
export type WindowConstraints = { right: string; bottom: string };
|
|
13
|
+
|
|
14
|
+
/** What the host browser supports, probed once at boot. */
|
|
15
|
+
export type ScaleCompatibility = {
|
|
16
|
+
supportsFullScreen: boolean;
|
|
17
|
+
orientationFallback: string | null;
|
|
18
|
+
noMargins: boolean;
|
|
19
|
+
canExpandParent: boolean;
|
|
20
|
+
clickTrampoline: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
export class ScaleManager {
|
|
9
24
|
public game!: Game;
|
|
10
25
|
public dom!: DOM;
|
|
@@ -24,32 +39,32 @@ export class ScaleManager {
|
|
|
24
39
|
public enterIncorrectOrientation!: Signal;
|
|
25
40
|
public leaveIncorrectOrientation!: Signal;
|
|
26
41
|
public hasPhaserSetFullScreen!: boolean;
|
|
27
|
-
public fullScreenTarget!:
|
|
28
|
-
public _createdFullScreenTarget!:
|
|
42
|
+
public fullScreenTarget!: HTMLElement | null;
|
|
43
|
+
public _createdFullScreenTarget!: HTMLElement | null;
|
|
29
44
|
public onFullScreenInit!: Signal;
|
|
30
45
|
public onFullScreenChange!: Signal;
|
|
31
46
|
public onFullScreenError!: Signal;
|
|
32
|
-
public screenOrientation!:
|
|
47
|
+
public screenOrientation!: string;
|
|
33
48
|
public scaleFactor!: Point;
|
|
34
49
|
public scaleFactorInversed!: Point;
|
|
35
|
-
public margin!:
|
|
50
|
+
public margin!: ScaleMargin;
|
|
36
51
|
public bounds!: Rectangle;
|
|
37
52
|
public aspectRatio!: number;
|
|
38
53
|
public sourceAspectRatio!: number;
|
|
39
54
|
public event!: Event | null | undefined;
|
|
40
|
-
public windowConstraints!:
|
|
41
|
-
public compatibility!:
|
|
55
|
+
public windowConstraints!: WindowConstraints;
|
|
56
|
+
public compatibility!: ScaleCompatibility;
|
|
42
57
|
public _scaleMode!: number;
|
|
43
58
|
public _fullScreenScaleMode!: number;
|
|
44
59
|
public parentIsWindow!: boolean;
|
|
45
|
-
public parentNode!:
|
|
60
|
+
public parentNode!: HTMLElement | null;
|
|
46
61
|
public parentScaleFactor!: Point;
|
|
47
62
|
public trackParentInterval!: number;
|
|
48
63
|
public onSizeChange!: Signal;
|
|
49
|
-
public onResize!:
|
|
50
|
-
public onResizeContext!:
|
|
51
|
-
public _pendingScaleMode!:
|
|
52
|
-
public _fullScreenRestore!:
|
|
64
|
+
public onResize!: Function | null;
|
|
65
|
+
public onResizeContext!: unknown;
|
|
66
|
+
public _pendingScaleMode!: number | null;
|
|
67
|
+
public _fullScreenRestore!: { targetWidth: string; targetHeight: string } | null;
|
|
53
68
|
public _gameSize!: Rectangle;
|
|
54
69
|
public _userScaleFactor!: Point;
|
|
55
70
|
public _userScaleTrim!: Point;
|
|
@@ -152,7 +167,7 @@ export class ScaleManager {
|
|
|
152
167
|
/**
|
|
153
168
|
* TBD.
|
|
154
169
|
*/
|
|
155
|
-
public boot() {
|
|
170
|
+
public boot(): void {
|
|
156
171
|
// Configure device-dependent compatibility
|
|
157
172
|
const compat = this.compatibility;
|
|
158
173
|
compat.supportsFullScreen = this.game.device.fullscreen;
|
|
@@ -165,20 +180,20 @@ export class ScaleManager {
|
|
|
165
180
|
}
|
|
166
181
|
// Configure event listeners
|
|
167
182
|
const scope = this;
|
|
168
|
-
this._orientationChange = (event) => {
|
|
183
|
+
this._orientationChange = (event): void => {
|
|
169
184
|
scope.orientationChange(event);
|
|
170
185
|
};
|
|
171
|
-
this._windowResize = (event) => {
|
|
186
|
+
this._windowResize = (event): void => {
|
|
172
187
|
scope.windowResize(event);
|
|
173
188
|
};
|
|
174
189
|
// This does not appear to be on the standards track
|
|
175
190
|
globalThis.addEventListener('orientationchange', this._orientationChange, false);
|
|
176
191
|
window.addEventListener('resize', this._windowResize, false);
|
|
177
192
|
if (this.compatibility.supportsFullScreen) {
|
|
178
|
-
this._fullScreenChange = (event) => {
|
|
193
|
+
this._fullScreenChange = (event): void => {
|
|
179
194
|
scope.fullScreenChange(event);
|
|
180
195
|
};
|
|
181
|
-
this._fullScreenError = (event) => {
|
|
196
|
+
this._fullScreenError = (event): void => {
|
|
182
197
|
scope.fullScreenError(event);
|
|
183
198
|
};
|
|
184
199
|
document.addEventListener('webkitfullscreenchange', this._fullScreenChange, false);
|
|
@@ -208,7 +223,7 @@ export class ScaleManager {
|
|
|
208
223
|
* TBD.
|
|
209
224
|
* @param {object} config - TBD.
|
|
210
225
|
*/
|
|
211
|
-
public parseConfig(config: any) {
|
|
226
|
+
public parseConfig(config: any): void {
|
|
212
227
|
if (config.scaleMode !== undefined) {
|
|
213
228
|
if (this._booted) {
|
|
214
229
|
this.scaleMode = config.scaleMode;
|
|
@@ -231,7 +246,7 @@ export class ScaleManager {
|
|
|
231
246
|
* @param {number} width - TBD.
|
|
232
247
|
* @param {number} height - TBD.
|
|
233
248
|
*/
|
|
234
|
-
public setupScale(width: number, height: number) {
|
|
249
|
+
public setupScale(width: number, height: number): void {
|
|
235
250
|
let target;
|
|
236
251
|
const rect = new Rectangle();
|
|
237
252
|
if (this.game.parent !== '') {
|
|
@@ -284,7 +299,7 @@ export class ScaleManager {
|
|
|
284
299
|
/**
|
|
285
300
|
* TBD.
|
|
286
301
|
*/
|
|
287
|
-
public _gameResumed() {
|
|
302
|
+
public _gameResumed(): void {
|
|
288
303
|
this.queueUpdate(true);
|
|
289
304
|
}
|
|
290
305
|
|
|
@@ -293,7 +308,7 @@ export class ScaleManager {
|
|
|
293
308
|
* @param {number} width - TBD.
|
|
294
309
|
* @param {number} height - TBD.
|
|
295
310
|
*/
|
|
296
|
-
public setGameSize(width: number, height: number) {
|
|
311
|
+
public setGameSize(width: number, height: number): void {
|
|
297
312
|
this._gameSize.setTo(0, 0, width, height);
|
|
298
313
|
if (this.currentScaleMode !== SCALE_RESIZE) {
|
|
299
314
|
this.updateDimensions(width, height, true);
|
|
@@ -308,7 +323,7 @@ export class ScaleManager {
|
|
|
308
323
|
* @param {number} hTrim - TBD.
|
|
309
324
|
* @param {number} vTrim - TBD.
|
|
310
325
|
*/
|
|
311
|
-
public setUserScale(hScale: number, vScale: number, hTrim: number, vTrim: number) {
|
|
326
|
+
public setUserScale(hScale: number, vScale: number, hTrim: number, vTrim: number): void {
|
|
312
327
|
this._userScaleFactor.setTo(hScale, vScale);
|
|
313
328
|
this._userScaleTrim.setTo(Math.trunc(hTrim), Math.trunc(vTrim));
|
|
314
329
|
this.queueUpdate(true);
|
|
@@ -319,7 +334,7 @@ export class ScaleManager {
|
|
|
319
334
|
* @param {Function} callback - TBD.
|
|
320
335
|
* @param {object} context - TBD.
|
|
321
336
|
*/
|
|
322
|
-
public setResizeCallback(callback: Function, context:
|
|
337
|
+
public setResizeCallback(callback: Function, context: unknown): void {
|
|
323
338
|
this.onResize = callback;
|
|
324
339
|
this.onResizeContext = context;
|
|
325
340
|
}
|
|
@@ -327,7 +342,7 @@ export class ScaleManager {
|
|
|
327
342
|
/**
|
|
328
343
|
* TBD.
|
|
329
344
|
*/
|
|
330
|
-
public signalSizeChange() {
|
|
345
|
+
public signalSizeChange(): void {
|
|
331
346
|
if (
|
|
332
347
|
this.width !== this._lastReportedCanvasSize.width ||
|
|
333
348
|
this.height !== this._lastReportedCanvasSize.height ||
|
|
@@ -354,7 +369,7 @@ export class ScaleManager {
|
|
|
354
369
|
* @param {number} maxWidth - TBD.
|
|
355
370
|
* @param {number} maxHeight - TBD.
|
|
356
371
|
*/
|
|
357
|
-
public setMinMax(minWidth: number, minHeight: number, maxWidth: number, maxHeight: number) {
|
|
372
|
+
public setMinMax(minWidth: number, minHeight: number, maxWidth: number, maxHeight: number): void {
|
|
358
373
|
this.minWidth = minWidth;
|
|
359
374
|
this.minHeight = minHeight;
|
|
360
375
|
if (maxWidth !== undefined) {
|
|
@@ -368,7 +383,7 @@ export class ScaleManager {
|
|
|
368
383
|
/**
|
|
369
384
|
* TBD.
|
|
370
385
|
*/
|
|
371
|
-
public preUpdate() {
|
|
386
|
+
public preUpdate(): void {
|
|
372
387
|
if (this.game.time.time < this._lastUpdate + this._updateThrottle) {
|
|
373
388
|
return;
|
|
374
389
|
}
|
|
@@ -401,7 +416,7 @@ export class ScaleManager {
|
|
|
401
416
|
/**
|
|
402
417
|
* TBD.
|
|
403
418
|
*/
|
|
404
|
-
public pauseUpdate() {
|
|
419
|
+
public pauseUpdate(): void {
|
|
405
420
|
this.preUpdate();
|
|
406
421
|
// Updates at slowest.
|
|
407
422
|
this._updateThrottle = this.trackParentInterval;
|
|
@@ -413,7 +428,7 @@ export class ScaleManager {
|
|
|
413
428
|
* @param {number} height - TBD.
|
|
414
429
|
* @param {boolean} resize - TBD.
|
|
415
430
|
*/
|
|
416
|
-
public updateDimensions(width: number, height: number, resize: boolean) {
|
|
431
|
+
public updateDimensions(width: number, height: number, resize: boolean): void {
|
|
417
432
|
this.width = width * this.parentScaleFactor.x;
|
|
418
433
|
this.height = height * this.parentScaleFactor.y;
|
|
419
434
|
this.game.width = this.width;
|
|
@@ -429,7 +444,7 @@ export class ScaleManager {
|
|
|
429
444
|
/**
|
|
430
445
|
* TBD.
|
|
431
446
|
*/
|
|
432
|
-
public updateScalingAndBounds() {
|
|
447
|
+
public updateScalingAndBounds(): void {
|
|
433
448
|
this.scaleFactor.x = this.game.width / this.width;
|
|
434
449
|
this.scaleFactor.y = this.game.height / this.height;
|
|
435
450
|
this.scaleFactorInversed.x = this.width / this.game.width;
|
|
@@ -451,7 +466,7 @@ export class ScaleManager {
|
|
|
451
466
|
* @param {boolean} forceLandscape - TBD.
|
|
452
467
|
* @param {boolean} forcePortrait - TBD.
|
|
453
468
|
*/
|
|
454
|
-
public forceOrientation(forceLandscape = false, forcePortrait = false) {
|
|
469
|
+
public forceOrientation(forceLandscape = false, forcePortrait = false): void {
|
|
455
470
|
this.forceLandscape = forceLandscape;
|
|
456
471
|
this.forcePortrait = forcePortrait;
|
|
457
472
|
this.queueUpdate(true);
|
|
@@ -462,7 +477,7 @@ export class ScaleManager {
|
|
|
462
477
|
* @param {string} orientation - TBD.
|
|
463
478
|
* @returns {string} TBD.
|
|
464
479
|
*/
|
|
465
|
-
public classifyOrientation(orientation: string) {
|
|
480
|
+
public classifyOrientation(orientation: string): 'portrait' | 'landscape' | null {
|
|
466
481
|
if (orientation === 'portrait-primary' || orientation === 'portrait-secondary') {
|
|
467
482
|
return 'portrait';
|
|
468
483
|
} else if (orientation === 'landscape-primary' || orientation === 'landscape-secondary') {
|
|
@@ -475,7 +490,7 @@ export class ScaleManager {
|
|
|
475
490
|
* TBD.
|
|
476
491
|
* @returns {boolean} TBD.
|
|
477
492
|
*/
|
|
478
|
-
public updateOrientationState() {
|
|
493
|
+
public updateOrientationState(): boolean {
|
|
479
494
|
const previousOrientation = this.screenOrientation;
|
|
480
495
|
const previouslyIncorrect = this.incorrectOrientation;
|
|
481
496
|
this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback);
|
|
@@ -499,7 +514,7 @@ export class ScaleManager {
|
|
|
499
514
|
* TBD.
|
|
500
515
|
* @param {Event} event - TBD.
|
|
501
516
|
*/
|
|
502
|
-
public orientationChange(event: Event) {
|
|
517
|
+
public orientationChange(event: Event): void {
|
|
503
518
|
this.event = event;
|
|
504
519
|
this.queueUpdate(true);
|
|
505
520
|
}
|
|
@@ -508,7 +523,7 @@ export class ScaleManager {
|
|
|
508
523
|
* TBD.
|
|
509
524
|
* @param {Event} event - TBD.
|
|
510
525
|
*/
|
|
511
|
-
public windowResize(event: Event) {
|
|
526
|
+
public windowResize(event: Event): void {
|
|
512
527
|
this.event = event;
|
|
513
528
|
this.queueUpdate(true);
|
|
514
529
|
}
|
|
@@ -516,14 +531,14 @@ export class ScaleManager {
|
|
|
516
531
|
/**
|
|
517
532
|
* TBD.
|
|
518
533
|
*/
|
|
519
|
-
public refresh() {
|
|
534
|
+
public refresh(): void {
|
|
520
535
|
this.queueUpdate(true);
|
|
521
536
|
}
|
|
522
537
|
|
|
523
538
|
/**
|
|
524
539
|
* TBD.
|
|
525
540
|
*/
|
|
526
|
-
public updateLayout() {
|
|
541
|
+
public updateLayout(): void {
|
|
527
542
|
const scaleMode = this.currentScaleMode;
|
|
528
543
|
if (scaleMode === SCALE_RESIZE) {
|
|
529
544
|
this.reflowGame();
|
|
@@ -567,7 +582,7 @@ export class ScaleManager {
|
|
|
567
582
|
* @param {Rectangle} target - TBD.
|
|
568
583
|
* @returns {Rectangle} TBD.
|
|
569
584
|
*/
|
|
570
|
-
public getParentBounds(target: Rectangle) {
|
|
585
|
+
public getParentBounds(target: Rectangle): Rectangle {
|
|
571
586
|
const bounds = target || new Rectangle();
|
|
572
587
|
const parentNode = this.boundingParent;
|
|
573
588
|
const { visualBounds } = this.dom;
|
|
@@ -605,7 +620,7 @@ export class ScaleManager {
|
|
|
605
620
|
* @param {boolean} horizontal - TBD.
|
|
606
621
|
* @param {boolean} vertical - TBD.
|
|
607
622
|
*/
|
|
608
|
-
public alignCanvas(horizontal: boolean, vertical: boolean) {
|
|
623
|
+
public alignCanvas(horizontal: boolean, vertical: boolean): void {
|
|
609
624
|
const parentBounds = this.getParentBounds(this._tempBounds);
|
|
610
625
|
const { canvas } = this.game;
|
|
611
626
|
const { margin } = this;
|
|
@@ -651,7 +666,7 @@ export class ScaleManager {
|
|
|
651
666
|
/**
|
|
652
667
|
* TBD.
|
|
653
668
|
*/
|
|
654
|
-
public reflowGame() {
|
|
669
|
+
public reflowGame(): void {
|
|
655
670
|
this.resetCanvas('', '');
|
|
656
671
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
657
672
|
this.updateDimensions(bounds.width, bounds.height, true);
|
|
@@ -660,7 +675,7 @@ export class ScaleManager {
|
|
|
660
675
|
/**
|
|
661
676
|
* TBD.
|
|
662
677
|
*/
|
|
663
|
-
public reflowCanvas() {
|
|
678
|
+
public reflowCanvas(): void {
|
|
664
679
|
if (!this.incorrectOrientation) {
|
|
665
680
|
this.width = Math.max(this.minWidth ?? 0, Math.min(this.maxWidth ?? this.width, this.width));
|
|
666
681
|
this.height = Math.max(this.minHeight ?? 0, Math.min(this.maxHeight ?? this.height, this.height));
|
|
@@ -681,7 +696,7 @@ export class ScaleManager {
|
|
|
681
696
|
* @param {string} cssWidth - TBD.
|
|
682
697
|
* @param {string} cssHeight - TBD.
|
|
683
698
|
*/
|
|
684
|
-
public resetCanvas(cssWidth = `${this.width}px`, cssHeight = `${this.height}px`) {
|
|
699
|
+
public resetCanvas(cssWidth = `${this.width}px`, cssHeight = `${this.height}px`): void {
|
|
685
700
|
const { canvas } = this.game;
|
|
686
701
|
if (!this.compatibility.noMargins) {
|
|
687
702
|
canvas.style.marginLeft = '';
|
|
@@ -697,7 +712,7 @@ export class ScaleManager {
|
|
|
697
712
|
* TBD.
|
|
698
713
|
* @param {boolean} force - TBD.
|
|
699
714
|
*/
|
|
700
|
-
public queueUpdate(force: boolean) {
|
|
715
|
+
public queueUpdate(force: boolean): void {
|
|
701
716
|
if (force) {
|
|
702
717
|
this._parentBounds.width = 0;
|
|
703
718
|
this._parentBounds.height = 0;
|
|
@@ -708,14 +723,14 @@ export class ScaleManager {
|
|
|
708
723
|
/**
|
|
709
724
|
* TBD.
|
|
710
725
|
*/
|
|
711
|
-
public reset() {
|
|
726
|
+
public reset(): void {
|
|
712
727
|
// pass
|
|
713
728
|
}
|
|
714
729
|
|
|
715
730
|
/**
|
|
716
731
|
* TBD.
|
|
717
732
|
*/
|
|
718
|
-
public setMaximum() {
|
|
733
|
+
public setMaximum(): void {
|
|
719
734
|
this.width = this.dom.visualBounds.width;
|
|
720
735
|
this.height = this.dom.visualBounds.height;
|
|
721
736
|
}
|
|
@@ -724,7 +739,7 @@ export class ScaleManager {
|
|
|
724
739
|
* TBD.
|
|
725
740
|
* @param {boolean} expanding - TBD.
|
|
726
741
|
*/
|
|
727
|
-
public setShowAll(expanding = false) {
|
|
742
|
+
public setShowAll(expanding = false): void {
|
|
728
743
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
729
744
|
const { width } = bounds;
|
|
730
745
|
const { height } = bounds;
|
|
@@ -741,7 +756,7 @@ export class ScaleManager {
|
|
|
741
756
|
/**
|
|
742
757
|
* TBD.
|
|
743
758
|
*/
|
|
744
|
-
public setExactFit() {
|
|
759
|
+
public setExactFit(): void {
|
|
745
760
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
746
761
|
this.width = bounds.width;
|
|
747
762
|
this.height = bounds.height;
|
|
@@ -761,7 +776,7 @@ export class ScaleManager {
|
|
|
761
776
|
* TBD.
|
|
762
777
|
* @returns {HTMLDivElement} TBD.
|
|
763
778
|
*/
|
|
764
|
-
public createFullScreenTarget() {
|
|
779
|
+
public createFullScreenTarget(): HTMLDivElement {
|
|
765
780
|
const fsTarget = document.createElement('div');
|
|
766
781
|
fsTarget.style.margin = '0';
|
|
767
782
|
fsTarget.style.padding = '0';
|
|
@@ -775,14 +790,14 @@ export class ScaleManager {
|
|
|
775
790
|
* @param {boolean} allowTrampoline - TBD.
|
|
776
791
|
* @returns {boolean} TBD.
|
|
777
792
|
*/
|
|
778
|
-
public startFullScreen(antialias: boolean, allowTrampoline: boolean) {
|
|
793
|
+
public startFullScreen(antialias: boolean, allowTrampoline: boolean): boolean {
|
|
779
794
|
if (this.isFullScreen) {
|
|
780
795
|
return false;
|
|
781
796
|
}
|
|
782
797
|
if (!this.compatibility.supportsFullScreen) {
|
|
783
798
|
// Error is called in timeout to emulate the real fullscreenerror event better
|
|
784
799
|
const scope = this;
|
|
785
|
-
setTimeout(() => {
|
|
800
|
+
setTimeout((): void => {
|
|
786
801
|
scope.fullScreenError({} as any);
|
|
787
802
|
}, 10);
|
|
788
803
|
return false;
|
|
@@ -815,10 +830,14 @@ export class ScaleManager {
|
|
|
815
830
|
}
|
|
816
831
|
fsTarget.append(canvas);
|
|
817
832
|
}
|
|
833
|
+
// The request method is vendor-prefixed, so it is looked up by the name the device reported.
|
|
834
|
+
const requestFullscreen = (fsTarget as unknown as Record<string, ((flag?: unknown) => void) | undefined>)[
|
|
835
|
+
this.game.device.requestFullscreen
|
|
836
|
+
];
|
|
818
837
|
if (this.game.device.fullscreenKeyboard) {
|
|
819
|
-
|
|
838
|
+
requestFullscreen?.call(fsTarget, (Element as unknown as { ALLOW_KEYBOARD_INPUT: unknown }).ALLOW_KEYBOARD_INPUT);
|
|
820
839
|
} else {
|
|
821
|
-
|
|
840
|
+
requestFullscreen?.call(fsTarget);
|
|
822
841
|
}
|
|
823
842
|
return true;
|
|
824
843
|
}
|
|
@@ -827,7 +846,7 @@ export class ScaleManager {
|
|
|
827
846
|
* TBD.
|
|
828
847
|
* @returns {boolean} TBD.
|
|
829
848
|
*/
|
|
830
|
-
public stopFullScreen() {
|
|
849
|
+
public stopFullScreen(): boolean {
|
|
831
850
|
if (!this.isFullScreen || !this.compatibility.supportsFullScreen) {
|
|
832
851
|
return false;
|
|
833
852
|
}
|
|
@@ -839,7 +858,7 @@ export class ScaleManager {
|
|
|
839
858
|
/**
|
|
840
859
|
* TBD.
|
|
841
860
|
*/
|
|
842
|
-
public cleanupCreatedTarget() {
|
|
861
|
+
public cleanupCreatedTarget(): void {
|
|
843
862
|
const fsTarget = this._createdFullScreenTarget;
|
|
844
863
|
if (fsTarget && fsTarget.parentNode) {
|
|
845
864
|
// Make sure to cleanup synthetic target for sure;
|
|
@@ -855,7 +874,7 @@ export class ScaleManager {
|
|
|
855
874
|
* TBD.
|
|
856
875
|
* @param {boolean} enteringFullscreen - TBD.
|
|
857
876
|
*/
|
|
858
|
-
public prepScreenMode(enteringFullscreen: boolean) {
|
|
877
|
+
public prepScreenMode(enteringFullscreen: boolean): void {
|
|
859
878
|
const fsTarget = this._createdFullScreenTarget ?? this.fullScreenTarget;
|
|
860
879
|
if (!fsTarget) {
|
|
861
880
|
return;
|
|
@@ -889,7 +908,7 @@ export class ScaleManager {
|
|
|
889
908
|
* TBD.
|
|
890
909
|
* @param {Event} event - TBD.
|
|
891
910
|
*/
|
|
892
|
-
public fullScreenChange(event: Event) {
|
|
911
|
+
public fullScreenChange(event: Event): void {
|
|
893
912
|
this.event = event;
|
|
894
913
|
if (this.isFullScreen) {
|
|
895
914
|
this.prepScreenMode(true);
|
|
@@ -908,7 +927,7 @@ export class ScaleManager {
|
|
|
908
927
|
* TBD.
|
|
909
928
|
* @param {Event} [event] - TBD.
|
|
910
929
|
*/
|
|
911
|
-
public fullScreenError(event: Event) {
|
|
930
|
+
public fullScreenError(event: Event): void {
|
|
912
931
|
this.event = event;
|
|
913
932
|
this.cleanupCreatedTarget();
|
|
914
933
|
this.onFullScreenError.dispatch(this);
|
|
@@ -917,7 +936,7 @@ export class ScaleManager {
|
|
|
917
936
|
/**
|
|
918
937
|
* TBD.
|
|
919
938
|
*/
|
|
920
|
-
public destroy() {
|
|
939
|
+
public destroy(): void {
|
|
921
940
|
this.game.onResume.remove(this._gameResumed, this);
|
|
922
941
|
globalThis.removeEventListener('orientationchange', this._orientationChange, false);
|
|
923
942
|
window.removeEventListener('resize', this._windowResize, false);
|
|
@@ -938,7 +957,7 @@ export class ScaleManager {
|
|
|
938
957
|
* TBD.
|
|
939
958
|
* @returns {ParentNode | null} TBD.
|
|
940
959
|
*/
|
|
941
|
-
public get boundingParent() {
|
|
960
|
+
public get boundingParent(): HTMLElement | null {
|
|
942
961
|
if (this.parentIsWindow || (this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget)) {
|
|
943
962
|
return null;
|
|
944
963
|
}
|
|
@@ -950,7 +969,7 @@ export class ScaleManager {
|
|
|
950
969
|
* TBD.
|
|
951
970
|
* @returns {number} TBD.
|
|
952
971
|
*/
|
|
953
|
-
public get scaleMode() {
|
|
972
|
+
public get scaleMode(): number {
|
|
954
973
|
return this._scaleMode;
|
|
955
974
|
}
|
|
956
975
|
|
|
@@ -972,7 +991,7 @@ export class ScaleManager {
|
|
|
972
991
|
* TBD.
|
|
973
992
|
* @returns {number} TBD.
|
|
974
993
|
*/
|
|
975
|
-
public get fullScreenScaleMode() {
|
|
994
|
+
public get fullScreenScaleMode(): number {
|
|
976
995
|
return this._fullScreenScaleMode;
|
|
977
996
|
}
|
|
978
997
|
|
|
@@ -998,7 +1017,7 @@ export class ScaleManager {
|
|
|
998
1017
|
* TBD.
|
|
999
1018
|
* @returns {number} TBD.
|
|
1000
1019
|
*/
|
|
1001
|
-
public get currentScaleMode() {
|
|
1020
|
+
public get currentScaleMode(): number {
|
|
1002
1021
|
return this.isFullScreen ? this._fullScreenScaleMode : this._scaleMode;
|
|
1003
1022
|
}
|
|
1004
1023
|
|
|
@@ -1006,7 +1025,7 @@ export class ScaleManager {
|
|
|
1006
1025
|
* TBD.
|
|
1007
1026
|
* @returns {boolean} TBD.
|
|
1008
1027
|
*/
|
|
1009
|
-
public get pageAlignHorizontally() {
|
|
1028
|
+
public get pageAlignHorizontally(): boolean {
|
|
1010
1029
|
return this._pageAlignHorizontally;
|
|
1011
1030
|
}
|
|
1012
1031
|
|
|
@@ -1014,7 +1033,7 @@ export class ScaleManager {
|
|
|
1014
1033
|
* TBD.
|
|
1015
1034
|
* @returns {boolean} TBD.
|
|
1016
1035
|
*/
|
|
1017
|
-
public get pageAlignVertically() {
|
|
1036
|
+
public get pageAlignVertically(): boolean {
|
|
1018
1037
|
return this._pageAlignVertically;
|
|
1019
1038
|
}
|
|
1020
1039
|
|
|
@@ -1022,7 +1041,7 @@ export class ScaleManager {
|
|
|
1022
1041
|
* TBD.
|
|
1023
1042
|
* @returns {boolean} TBD.
|
|
1024
1043
|
*/
|
|
1025
|
-
public get isFullScreen() {
|
|
1044
|
+
public get isFullScreen(): boolean {
|
|
1026
1045
|
return Boolean(
|
|
1027
1046
|
document.fullscreenElement ??
|
|
1028
1047
|
(document as any).webkitFullscreenElement ??
|
|
@@ -1035,7 +1054,7 @@ export class ScaleManager {
|
|
|
1035
1054
|
* TBD.
|
|
1036
1055
|
* @returns {boolean} TBD.
|
|
1037
1056
|
*/
|
|
1038
|
-
public get isPortrait() {
|
|
1057
|
+
public get isPortrait(): boolean {
|
|
1039
1058
|
return this.classifyOrientation(this.screenOrientation) === 'portrait';
|
|
1040
1059
|
}
|
|
1041
1060
|
|
|
@@ -1043,7 +1062,7 @@ export class ScaleManager {
|
|
|
1043
1062
|
* TBD.
|
|
1044
1063
|
* @returns {boolean} TBD.
|
|
1045
1064
|
*/
|
|
1046
|
-
public get isLandscape() {
|
|
1065
|
+
public get isLandscape(): boolean {
|
|
1047
1066
|
return this.classifyOrientation(this.screenOrientation) === 'landscape';
|
|
1048
1067
|
}
|
|
1049
1068
|
|
|
@@ -1051,7 +1070,7 @@ export class ScaleManager {
|
|
|
1051
1070
|
* TBD.
|
|
1052
1071
|
* @returns {boolean} TBD.
|
|
1053
1072
|
*/
|
|
1054
|
-
public get isGamePortrait() {
|
|
1073
|
+
public get isGamePortrait(): boolean {
|
|
1055
1074
|
return this.height > this.width;
|
|
1056
1075
|
}
|
|
1057
1076
|
|
|
@@ -1059,7 +1078,7 @@ export class ScaleManager {
|
|
|
1059
1078
|
* TBD.
|
|
1060
1079
|
* @returns {boolean} TBD.
|
|
1061
1080
|
*/
|
|
1062
|
-
public get isGameLandscape() {
|
|
1081
|
+
public get isGameLandscape(): boolean {
|
|
1063
1082
|
return this.width > this.height;
|
|
1064
1083
|
}
|
|
1065
1084
|
}
|
package/src/phaser/core/scene.ts
CHANGED
|
@@ -9,7 +9,7 @@ export class Scene {
|
|
|
9
9
|
* Initialize the scene.
|
|
10
10
|
* This method is called before preload() and create().
|
|
11
11
|
*/
|
|
12
|
-
public init() {
|
|
12
|
+
public init(): void {
|
|
13
13
|
// inherit
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ export class Scene {
|
|
|
17
17
|
* Load assets for the scene.
|
|
18
18
|
* This method is called after init() and before create().
|
|
19
19
|
*/
|
|
20
|
-
public preload() {
|
|
20
|
+
public preload(): void {
|
|
21
21
|
// inherit
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ export class Scene {
|
|
|
25
25
|
* Create the scene.
|
|
26
26
|
* This method is called after preload() and is where you create your game objects.
|
|
27
27
|
*/
|
|
28
|
-
public create() {
|
|
28
|
+
public create(): void {
|
|
29
29
|
// inherit
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -33,7 +33,7 @@ export class Scene {
|
|
|
33
33
|
* Update the scene.
|
|
34
34
|
* This method is called every frame while the scene is active.
|
|
35
35
|
*/
|
|
36
|
-
public update() {
|
|
36
|
+
public update(): void {
|
|
37
37
|
// inherit
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ export class Scene {
|
|
|
42
42
|
* @param {number} _width - The new width of the scene.
|
|
43
43
|
* @param {number} _height - The new height of the scene.
|
|
44
44
|
*/
|
|
45
|
-
public resize(_width: number, _height: number) {
|
|
45
|
+
public resize(_width: number, _height: number): void {
|
|
46
46
|
// inherit
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -50,7 +50,7 @@ export class Scene {
|
|
|
50
50
|
* Update the scene while paused.
|
|
51
51
|
* This method is called every frame while the scene is paused.
|
|
52
52
|
*/
|
|
53
|
-
public pauseUpdate() {
|
|
53
|
+
public pauseUpdate(): void {
|
|
54
54
|
// inherit
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -58,7 +58,7 @@ export class Scene {
|
|
|
58
58
|
* Shutdown the scene.
|
|
59
59
|
* This method is called when the scene is about to be destroyed.
|
|
60
60
|
*/
|
|
61
|
-
public shutdown() {
|
|
61
|
+
public shutdown(): void {
|
|
62
62
|
// inherit
|
|
63
63
|
}
|
|
64
64
|
}
|