@vpmedia/phaser 1.112.0 → 1.113.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 +1261 -1314
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +14 -10
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +10 -8
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +5 -4
- 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 +4 -3
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/const.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +3 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +8 -6
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +40 -30
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +3 -2
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +3 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +6 -4
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +3 -2
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +4 -3
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +9 -8
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +3 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/registry.d.ts +7 -0
- package/dist/phaser/core/registry.d.ts.map +1 -0
- package/dist/phaser/core/scale_manager.d.ts +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +0 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +0 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +4 -3
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +6 -4
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +3 -2
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +5 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -2
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +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/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +10 -7
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +3 -2
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +3 -2
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +3 -2
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -2
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +3 -2
- 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 +7 -6
- package/dist/phaser/display/canvas/graphics.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 +10 -8
- 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 +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +14 -12
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +8 -5
- 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 +4 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +13 -10
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +18 -15
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +11 -9
- 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.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +7 -6
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +16 -11
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +3 -2
- 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 +4 -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 +1 -1
- package/dist/phaser/geom/line.d.ts.map +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 +3 -2
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -2
- 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/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/phaser/core/animation.ts +64 -60
- package/src/phaser/core/animation_manager.ts +50 -53
- package/src/phaser/core/animation_parser.ts +9 -9
- package/src/phaser/core/array_set.ts +16 -17
- package/src/phaser/core/cache.ts +92 -93
- package/src/phaser/core/const.ts +1 -1
- package/src/phaser/core/device.ts +24 -29
- package/src/phaser/core/device_util.ts +22 -26
- package/src/phaser/core/dom.ts +54 -65
- package/src/phaser/core/event_manager.ts +64 -94
- package/src/phaser/core/factory.ts +14 -14
- package/src/phaser/core/frame.ts +28 -28
- package/src/phaser/core/frame_data.test.ts +100 -0
- package/src/phaser/core/frame_data.ts +24 -24
- package/src/phaser/core/frame_util.ts +2 -2
- package/src/phaser/core/game.ts +47 -48
- package/src/phaser/core/input.ts +104 -110
- package/src/phaser/core/input_handler.test.ts +113 -0
- package/src/phaser/core/input_handler.ts +199 -218
- package/src/phaser/core/input_mouse.ts +71 -54
- package/src/phaser/core/input_mspointer.ts +52 -39
- package/src/phaser/core/input_pointer.ts +81 -80
- package/src/phaser/core/input_touch.ts +49 -36
- package/src/phaser/core/loader.ts +173 -152
- package/src/phaser/core/loader_parser.ts +39 -57
- package/src/phaser/core/raf.ts +8 -7
- package/src/phaser/core/registry.test.ts +31 -0
- package/src/phaser/core/registry.ts +9 -0
- package/src/phaser/core/scale_manager.ts +156 -152
- package/src/phaser/core/scene.ts +9 -13
- package/src/phaser/core/scene_manager.ts +47 -47
- package/src/phaser/core/signal.test.ts +4 -4
- package/src/phaser/core/signal.ts +41 -52
- package/src/phaser/core/signal_binding.ts +26 -25
- package/src/phaser/core/signal_dispatch.test.ts +180 -0
- package/src/phaser/core/sound.ts +75 -83
- package/src/phaser/core/sound_manager.ts +52 -51
- package/src/phaser/core/sound_sprite.ts +17 -16
- package/src/phaser/core/stage.ts +25 -24
- package/src/phaser/core/time.ts +52 -52
- package/src/phaser/core/timer.test.ts +187 -0
- package/src/phaser/core/timer.ts +82 -69
- package/src/phaser/core/timer_event.ts +10 -10
- package/src/phaser/core/tween.ts +90 -93
- package/src/phaser/core/tween_data.ts +45 -51
- package/src/phaser/core/tween_easing.test.ts +106 -0
- package/src/phaser/core/tween_easing.ts +151 -123
- package/src/phaser/core/tween_manager.ts +19 -18
- package/src/phaser/core/world.ts +4 -3
- package/src/phaser/display/bitmap_text.ts +56 -64
- package/src/phaser/display/button.ts +33 -32
- package/src/phaser/display/canvas/buffer.ts +8 -8
- package/src/phaser/display/canvas/graphics.ts +36 -37
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.test.ts +106 -0
- package/src/phaser/display/canvas/pool.ts +25 -27
- package/src/phaser/display/canvas/renderer.ts +32 -31
- package/src/phaser/display/canvas/tinter.ts +25 -25
- package/src/phaser/display/canvas/util.ts +7 -10
- package/src/phaser/display/display_object.ts +114 -118
- package/src/phaser/display/graphics.ts +121 -119
- package/src/phaser/display/graphics_data.ts +12 -12
- package/src/phaser/display/graphics_data_util.ts +2 -3
- package/src/phaser/display/group.ts +50 -57
- package/src/phaser/display/image.ts +55 -52
- package/src/phaser/display/sprite_batch.ts +3 -2
- package/src/phaser/display/sprite_util.ts +48 -54
- package/src/phaser/display/text.ts +199 -204
- package/src/phaser/display/webgl/abstract_filter.ts +9 -9
- package/src/phaser/display/webgl/base_texture.ts +21 -24
- package/src/phaser/display/webgl/blend_manager.ts +6 -10
- package/src/phaser/display/webgl/earcut.ts +73 -37
- package/src/phaser/display/webgl/earcut_node.ts +10 -10
- package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
- package/src/phaser/display/webgl/filter_manager.ts +13 -12
- package/src/phaser/display/webgl/filter_texture.ts +14 -13
- package/src/phaser/display/webgl/graphics.ts +51 -57
- package/src/phaser/display/webgl/graphics_data.ts +15 -14
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +26 -25
- package/src/phaser/display/webgl/renderer.ts +57 -62
- package/src/phaser/display/webgl/shader/complex.ts +28 -12
- package/src/phaser/display/webgl/shader/fast.ts +30 -12
- package/src/phaser/display/webgl/shader/normal.ts +70 -57
- package/src/phaser/display/webgl/shader/primitive.ts +26 -11
- package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
- package/src/phaser/display/webgl/shader/strip.ts +27 -12
- package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
- package/src/phaser/display/webgl/shader_manager.ts +26 -34
- package/src/phaser/display/webgl/sprite_batch.ts +67 -61
- package/src/phaser/display/webgl/stencil_manager.ts +23 -34
- package/src/phaser/display/webgl/texture.ts +43 -50
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +26 -25
- package/src/phaser/geom/circle.test.ts +2 -3
- package/src/phaser/geom/circle.ts +36 -36
- package/src/phaser/geom/ellipse.test.ts +73 -71
- package/src/phaser/geom/ellipse.ts +14 -14
- package/src/phaser/geom/line.test.ts +5 -5
- package/src/phaser/geom/line.ts +35 -35
- package/src/phaser/geom/matrix.test.ts +1 -1
- package/src/phaser/geom/matrix.ts +27 -27
- package/src/phaser/geom/point.test.ts +1 -2
- package/src/phaser/geom/point.ts +35 -35
- package/src/phaser/geom/polygon.test.ts +82 -0
- package/src/phaser/geom/polygon.ts +16 -16
- package/src/phaser/geom/rectangle.test.ts +14 -14
- package/src/phaser/geom/rectangle.ts +83 -75
- package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
- package/src/phaser/geom/rounded_rectangle.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +25 -23
- package/src/phaser/geom/util/circle.ts +9 -18
- package/src/phaser/geom/util/ellipse.test.ts +7 -5
- package/src/phaser/geom/util/ellipse.ts +3 -2
- package/src/phaser/geom/util/line.test.ts +10 -8
- package/src/phaser/geom/util/line.ts +6 -16
- package/src/phaser/geom/util/matrix.test.ts +20 -18
- package/src/phaser/geom/util/matrix.ts +8 -15
- package/src/phaser/geom/util/point.test.ts +8 -6
- package/src/phaser/geom/util/point.ts +24 -28
- package/src/phaser/geom/util/polygon.test.ts +12 -10
- package/src/phaser/geom/util/polygon.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +10 -8
- package/src/phaser/geom/util/rectangle.ts +18 -37
- package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.test.ts +11 -11
- package/src/phaser/util/math.ts +29 -46
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Game } from './game.js';
|
|
1
2
|
import { GROUP } from './const.js';
|
|
2
3
|
import { Tween } from './tween.js';
|
|
3
4
|
import {
|
|
@@ -35,15 +36,15 @@ import {
|
|
|
35
36
|
} from './tween_easing.js';
|
|
36
37
|
|
|
37
38
|
export class TweenManager {
|
|
38
|
-
game!: any;
|
|
39
|
-
_tweens!: any;
|
|
40
|
-
_add!: any;
|
|
41
|
-
easeMap!: any;
|
|
39
|
+
public game!: any;
|
|
40
|
+
public _tweens!: any;
|
|
41
|
+
public _add!: any;
|
|
42
|
+
public easeMap!: any;
|
|
42
43
|
/**
|
|
43
44
|
* Creates a new TweenManager instance.
|
|
44
|
-
* @param {
|
|
45
|
+
* @param {Game} game - The game instance this manager belongs to.
|
|
45
46
|
*/
|
|
46
|
-
constructor(game:
|
|
47
|
+
public constructor(game: Game) {
|
|
47
48
|
this.game = game;
|
|
48
49
|
/** @type {Tween[]} */
|
|
49
50
|
this._tweens = [];
|
|
@@ -102,7 +103,7 @@ export class TweenManager {
|
|
|
102
103
|
* Get all tweens managed by this manager.
|
|
103
104
|
* @returns {Tween[]} An array of all active tweens.
|
|
104
105
|
*/
|
|
105
|
-
getAll() {
|
|
106
|
+
public getAll() {
|
|
106
107
|
return this._tweens;
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -110,7 +111,7 @@ export class TweenManager {
|
|
|
110
111
|
* Remove all tweens from the manager.
|
|
111
112
|
* This method removes all active and pending tweens.
|
|
112
113
|
*/
|
|
113
|
-
removeAll() {
|
|
114
|
+
public removeAll() {
|
|
114
115
|
for (let i = 0; i < this._tweens.length; i += 1) {
|
|
115
116
|
this._tweens[i].pendingDelete = true;
|
|
116
117
|
}
|
|
@@ -122,7 +123,7 @@ export class TweenManager {
|
|
|
122
123
|
* @param {object} obj - The object to remove tweens from.
|
|
123
124
|
* @param {object[]} children - Optional array of child objects to remove tweens from.
|
|
124
125
|
*/
|
|
125
|
-
removeFrom(obj: any, children: any[] | null = null) {
|
|
126
|
+
public removeFrom(obj: any, children: any[] | null = null) {
|
|
126
127
|
let i;
|
|
127
128
|
let len;
|
|
128
129
|
if (Array.isArray(obj)) {
|
|
@@ -151,7 +152,7 @@ export class TweenManager {
|
|
|
151
152
|
* Add a tween to the manager.
|
|
152
153
|
* @param {Tween} tween - The tween to add.
|
|
153
154
|
*/
|
|
154
|
-
add(tween: Tween) {
|
|
155
|
+
public add(tween: Tween) {
|
|
155
156
|
tween.manager = this;
|
|
156
157
|
this._add.push(tween);
|
|
157
158
|
}
|
|
@@ -161,7 +162,7 @@ export class TweenManager {
|
|
|
161
162
|
* @param {object} object - The object to create a tween for.
|
|
162
163
|
* @returns {Tween} The created Tween object.
|
|
163
164
|
*/
|
|
164
|
-
create(object: any) {
|
|
165
|
+
public create(object: any) {
|
|
165
166
|
return new Tween(object, this.game, this);
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -169,7 +170,7 @@ export class TweenManager {
|
|
|
169
170
|
* Remove a tween from the manager.
|
|
170
171
|
* @param {Tween | null | undefined} tween - The tween to remove.
|
|
171
172
|
*/
|
|
172
|
-
remove(tween: Tween | null | undefined) {
|
|
173
|
+
public remove(tween: Tween | null | undefined) {
|
|
173
174
|
let i = this._tweens.indexOf(tween);
|
|
174
175
|
if (i !== -1) {
|
|
175
176
|
this._tweens[i].pendingDelete = true;
|
|
@@ -185,7 +186,7 @@ export class TweenManager {
|
|
|
185
186
|
* Update all tweens managed by this manager.
|
|
186
187
|
* @returns {boolean} True if any tweens were updated, false otherwise.
|
|
187
188
|
*/
|
|
188
|
-
update() {
|
|
189
|
+
public update() {
|
|
189
190
|
const addTweens = this._add.length;
|
|
190
191
|
let numTweens = this._tweens.length;
|
|
191
192
|
if (numTweens === 0 && addTweens === 0) {
|
|
@@ -213,7 +214,7 @@ export class TweenManager {
|
|
|
213
214
|
* @param {object} object - The object to check.
|
|
214
215
|
* @returns {boolean} True if the object is being tweened, false otherwise.
|
|
215
216
|
*/
|
|
216
|
-
isTweening(object: unknown): boolean {
|
|
217
|
+
public isTweening(object: unknown): boolean {
|
|
217
218
|
return (this._tweens as Tween[]).some((tween: Tween) => tween.target === object);
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -221,7 +222,7 @@ export class TweenManager {
|
|
|
221
222
|
* Pause all tweens managed by this manager.
|
|
222
223
|
* This method pauses all active tweens.
|
|
223
224
|
*/
|
|
224
|
-
_pauseAll() {
|
|
225
|
+
public _pauseAll() {
|
|
225
226
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
226
227
|
this._tweens[i]._pause();
|
|
227
228
|
}
|
|
@@ -231,7 +232,7 @@ export class TweenManager {
|
|
|
231
232
|
* Resume all tweens managed by this manager.
|
|
232
233
|
* This method resumes all paused tweens.
|
|
233
234
|
*/
|
|
234
|
-
_resumeAll() {
|
|
235
|
+
public _resumeAll() {
|
|
235
236
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
236
237
|
this._tweens[i]._resume();
|
|
237
238
|
}
|
|
@@ -241,7 +242,7 @@ export class TweenManager {
|
|
|
241
242
|
* Pause all tweens managed by this manager.
|
|
242
243
|
* This method pauses all active tweens.
|
|
243
244
|
*/
|
|
244
|
-
pauseAll() {
|
|
245
|
+
public pauseAll() {
|
|
245
246
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
246
247
|
this._tweens[i].pause();
|
|
247
248
|
}
|
|
@@ -251,7 +252,7 @@ export class TweenManager {
|
|
|
251
252
|
* Resume all tweens managed by this manager.
|
|
252
253
|
* This method resumes all paused tweens.
|
|
253
254
|
*/
|
|
254
|
-
resumeAll() {
|
|
255
|
+
public resumeAll() {
|
|
255
256
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
256
257
|
this._tweens[i].resume(true);
|
|
257
258
|
}
|
package/src/phaser/core/world.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Group } from '../display/group.js';
|
|
2
|
+
import type { Game } from './game.js';
|
|
2
3
|
|
|
3
4
|
export class World extends Group {
|
|
4
5
|
/**
|
|
5
6
|
* Creates a new World instance.
|
|
6
|
-
* @param {
|
|
7
|
+
* @param {Game} game - The game instance this world belongs to.
|
|
7
8
|
*/
|
|
8
|
-
constructor(game:
|
|
9
|
+
public constructor(game: Game) {
|
|
9
10
|
super(game, null, '__world', false);
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -13,7 +14,7 @@ export class World extends Group {
|
|
|
13
14
|
* Initialize the world.
|
|
14
15
|
* This method is called when the game boots and sets up the world.
|
|
15
16
|
*/
|
|
16
|
-
boot() {
|
|
17
|
+
public boot() {
|
|
17
18
|
this.game.stage.addChild(this);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -2,26 +2,27 @@ import { BITMAP_TEXT, SCALE_LINEAR, SCALE_NEAREST } from '../core/const.js';
|
|
|
2
2
|
import { Point } from '../geom/point.js';
|
|
3
3
|
import { DisplayObject } from './display_object.js';
|
|
4
4
|
import { Image } from './image.js';
|
|
5
|
+
import type { Game } from '../core/game.js';
|
|
5
6
|
|
|
6
7
|
export class BitmapText extends DisplayObject {
|
|
7
|
-
declare type: number;
|
|
8
|
-
pendingDestroy!: boolean;
|
|
9
|
-
declare renderOrderID: number;
|
|
10
|
-
textWidth!: number;
|
|
11
|
-
textHeight!: number;
|
|
12
|
-
_prevAnchor!: Point;
|
|
13
|
-
_glyphs!: Image[];
|
|
14
|
-
_maxWidth!: number;
|
|
15
|
-
_text!: string;
|
|
16
|
-
_data!: any;
|
|
17
|
-
_font!: string;
|
|
18
|
-
_fontSize!: number;
|
|
19
|
-
_align!: string;
|
|
20
|
-
_tint!: number;
|
|
21
|
-
dirty!: boolean;
|
|
8
|
+
declare public type: number;
|
|
9
|
+
public pendingDestroy!: boolean;
|
|
10
|
+
declare public renderOrderID: number;
|
|
11
|
+
public textWidth!: number;
|
|
12
|
+
public textHeight!: number;
|
|
13
|
+
public _prevAnchor!: Point;
|
|
14
|
+
public _glyphs!: Image[];
|
|
15
|
+
public _maxWidth!: number;
|
|
16
|
+
public _text!: string;
|
|
17
|
+
public _data!: any;
|
|
18
|
+
public _font!: string;
|
|
19
|
+
public _fontSize!: number;
|
|
20
|
+
public _align!: string;
|
|
21
|
+
public _tint!: number;
|
|
22
|
+
public dirty!: boolean;
|
|
22
23
|
/**
|
|
23
24
|
* Creates a new BitmapText instance.
|
|
24
|
-
* @param {
|
|
25
|
+
* @param {Game} game - The game instance this bitmap text belongs to.
|
|
25
26
|
* @param {number} x - The x position of the bitmap text.
|
|
26
27
|
* @param {number} y - The y position of the bitmap text.
|
|
27
28
|
* @param {string} font - The key of the bitmap font to use.
|
|
@@ -29,15 +30,7 @@ export class BitmapText extends DisplayObject {
|
|
|
29
30
|
* @param {number} size - The font size.
|
|
30
31
|
* @param {string} align - The text alignment (left, center, right).
|
|
31
32
|
*/
|
|
32
|
-
constructor(
|
|
33
|
-
game: import('../core/game.js').Game,
|
|
34
|
-
x: number = 0,
|
|
35
|
-
y: number = 0,
|
|
36
|
-
font: string = '',
|
|
37
|
-
text: string = '',
|
|
38
|
-
size: number = 32,
|
|
39
|
-
align: string = 'left'
|
|
40
|
-
) {
|
|
33
|
+
public constructor(game: Game, x = 0, y = 0, font = '', text = '', size = 32, align = 'left') {
|
|
41
34
|
super(game);
|
|
42
35
|
this.type = BITMAP_TEXT;
|
|
43
36
|
this.position.setTo(x, y);
|
|
@@ -46,7 +39,7 @@ export class BitmapText extends DisplayObject {
|
|
|
46
39
|
this._prevAnchor = new Point();
|
|
47
40
|
this._glyphs = [];
|
|
48
41
|
this._maxWidth = 0;
|
|
49
|
-
this._text = text
|
|
42
|
+
this._text = text || '';
|
|
50
43
|
this._data = game.cache.getBitmapFont(font);
|
|
51
44
|
this._font = font;
|
|
52
45
|
this._fontSize = size;
|
|
@@ -59,7 +52,7 @@ export class BitmapText extends DisplayObject {
|
|
|
59
52
|
/**
|
|
60
53
|
* Destroys this bitmap text and cleans up resources.
|
|
61
54
|
*/
|
|
62
|
-
override destroy() {
|
|
55
|
+
public override destroy() {
|
|
63
56
|
this._prevAnchor = null!;
|
|
64
57
|
this._glyphs = null!;
|
|
65
58
|
this._text = null!;
|
|
@@ -70,7 +63,7 @@ export class BitmapText extends DisplayObject {
|
|
|
70
63
|
/**
|
|
71
64
|
* Called before the update cycle for this bitmap text.
|
|
72
65
|
*/
|
|
73
|
-
override preUpdate() {
|
|
66
|
+
public override preUpdate() {
|
|
74
67
|
if (this.pendingDestroy) {
|
|
75
68
|
this.destroy();
|
|
76
69
|
return;
|
|
@@ -84,8 +77,8 @@ export class BitmapText extends DisplayObject {
|
|
|
84
77
|
this.game.stage.currentRenderOrderID += 1;
|
|
85
78
|
this.renderOrderID = this.game.stage.currentRenderOrderID;
|
|
86
79
|
}
|
|
87
|
-
for (
|
|
88
|
-
|
|
80
|
+
for (const child of this.children) {
|
|
81
|
+
child.preUpdate();
|
|
89
82
|
}
|
|
90
83
|
}
|
|
91
84
|
|
|
@@ -93,7 +86,7 @@ export class BitmapText extends DisplayObject {
|
|
|
93
86
|
* Sets the text to display.
|
|
94
87
|
* @param {string} text - The new text to display.
|
|
95
88
|
*/
|
|
96
|
-
setText(text: string) {
|
|
89
|
+
public setText(text: string) {
|
|
97
90
|
this.text = text;
|
|
98
91
|
}
|
|
99
92
|
|
|
@@ -104,7 +97,7 @@ export class BitmapText extends DisplayObject {
|
|
|
104
97
|
* @param {string} text - The text to scan.
|
|
105
98
|
* @returns {{width: number, text: string, end: boolean, chars: number[]}} An object containing the width, processed text, end status, and character positions.
|
|
106
99
|
*/
|
|
107
|
-
scanLine(data: any, scale: number, text: string) {
|
|
100
|
+
public scanLine(data: any, scale: number, text: string) {
|
|
108
101
|
let x = 0;
|
|
109
102
|
let w = 0;
|
|
110
103
|
let lastSpace = -1;
|
|
@@ -171,7 +164,7 @@ export class BitmapText extends DisplayObject {
|
|
|
171
164
|
* @param {string} replace - The character to use for replacement of invalid characters (default: '').
|
|
172
165
|
* @returns {string} The cleaned text.
|
|
173
166
|
*/
|
|
174
|
-
cleanText(text: string, replace
|
|
167
|
+
public cleanText(text: string, replace = '') {
|
|
175
168
|
const data = this._data.font;
|
|
176
169
|
if (!data) {
|
|
177
170
|
return '';
|
|
@@ -179,11 +172,11 @@ export class BitmapText extends DisplayObject {
|
|
|
179
172
|
const re = /\r\n|\n\r|\n|\r/g;
|
|
180
173
|
const lines = text.replace(re, '\n').split('\n');
|
|
181
174
|
for (let i = 0; i < lines.length; i += 1) {
|
|
175
|
+
const line = lines[i]!;
|
|
182
176
|
let output = '';
|
|
183
|
-
const line = lines[i];
|
|
184
177
|
for (let c = 0; c < line.length; c += 1) {
|
|
185
178
|
if (data.chars[line.charCodeAt(c)]) {
|
|
186
|
-
output = output.concat(line[c]);
|
|
179
|
+
output = output.concat(line[c]!);
|
|
187
180
|
} else {
|
|
188
181
|
output = output.concat(replace);
|
|
189
182
|
}
|
|
@@ -196,7 +189,7 @@ export class BitmapText extends DisplayObject {
|
|
|
196
189
|
/**
|
|
197
190
|
* Updates the internal text rendering based on current properties and content.
|
|
198
191
|
*/
|
|
199
|
-
updateText() {
|
|
192
|
+
public updateText() {
|
|
200
193
|
const data = this._data.font;
|
|
201
194
|
if (!data) {
|
|
202
195
|
return;
|
|
@@ -215,15 +208,14 @@ export class BitmapText extends DisplayObject {
|
|
|
215
208
|
this.textWidth = line.width;
|
|
216
209
|
}
|
|
217
210
|
y += data.lineHeight * scale;
|
|
218
|
-
text = text.
|
|
211
|
+
text = text.slice(line.text.length + 1);
|
|
219
212
|
} while (line.end === false);
|
|
220
213
|
this.textHeight = y;
|
|
221
214
|
let t = 0;
|
|
222
215
|
let align = 0;
|
|
223
216
|
const ax = this.textWidth * this.anchor.x;
|
|
224
217
|
const ay = this.textHeight * this.anchor.y;
|
|
225
|
-
for (
|
|
226
|
-
const currentLine = lines[i];
|
|
218
|
+
for (const currentLine of lines) {
|
|
227
219
|
if (this._align === 'right') {
|
|
228
220
|
align = this.textWidth - currentLine.width;
|
|
229
221
|
} else if (this._align === 'center') {
|
|
@@ -260,7 +252,7 @@ export class BitmapText extends DisplayObject {
|
|
|
260
252
|
// Remove unnecessary children
|
|
261
253
|
// This moves them from the display list (children array) but retains them in the _glyphs pool
|
|
262
254
|
for (let i = t; i < this._glyphs.length; i += 1) {
|
|
263
|
-
this.removeChild(this._glyphs[i]);
|
|
255
|
+
this.removeChild(this._glyphs[i]!);
|
|
264
256
|
}
|
|
265
257
|
}
|
|
266
258
|
|
|
@@ -268,14 +260,14 @@ export class BitmapText extends DisplayObject {
|
|
|
268
260
|
* Removes unused glyphs from the pool and returns the number removed.
|
|
269
261
|
* @returns {number} The number of glyphs that were removed from the pool.
|
|
270
262
|
*/
|
|
271
|
-
purgeGlyphs() {
|
|
263
|
+
public purgeGlyphs() {
|
|
272
264
|
const len = this._glyphs.length;
|
|
273
265
|
const kept = [];
|
|
274
|
-
for (
|
|
275
|
-
if (
|
|
276
|
-
|
|
266
|
+
for (const glyph of this._glyphs) {
|
|
267
|
+
if (glyph.parent !== this) {
|
|
268
|
+
glyph.destroy();
|
|
277
269
|
} else {
|
|
278
|
-
kept.push(
|
|
270
|
+
kept.push(glyph);
|
|
279
271
|
}
|
|
280
272
|
}
|
|
281
273
|
this._glyphs = [];
|
|
@@ -287,7 +279,7 @@ export class BitmapText extends DisplayObject {
|
|
|
287
279
|
/**
|
|
288
280
|
* Updates the transform of this bitmap text, updating its text if needed.
|
|
289
281
|
*/
|
|
290
|
-
override updateTransform(): this {
|
|
282
|
+
public override updateTransform(): this {
|
|
291
283
|
if (this.dirty || !this.anchor.equals(this._prevAnchor)) {
|
|
292
284
|
this.updateText();
|
|
293
285
|
this.dirty = false;
|
|
@@ -303,7 +295,7 @@ export class BitmapText extends DisplayObject {
|
|
|
303
295
|
* @param {number} _position - The character position to apply the color to.
|
|
304
296
|
* @returns {BitmapText} This bitmap text instance for chaining.
|
|
305
297
|
*/
|
|
306
|
-
addColor(value: string, _position: number) {
|
|
298
|
+
public addColor(value: string, _position: number) {
|
|
307
299
|
const color = typeof value === 'string' ? Number.parseInt(value.replace('#', ''), 16) : value;
|
|
308
300
|
if (color !== this._tint) {
|
|
309
301
|
this._tint = color;
|
|
@@ -316,7 +308,7 @@ export class BitmapText extends DisplayObject {
|
|
|
316
308
|
* Gets the text alignment property.
|
|
317
309
|
* @returns {string} The current text alignment (left, center, right).
|
|
318
310
|
*/
|
|
319
|
-
get align() {
|
|
311
|
+
public get align() {
|
|
320
312
|
return this._align;
|
|
321
313
|
}
|
|
322
314
|
|
|
@@ -324,7 +316,7 @@ export class BitmapText extends DisplayObject {
|
|
|
324
316
|
* Sets the text alignment property.
|
|
325
317
|
* @param {string} value - The new text alignment (left, center, right).
|
|
326
318
|
*/
|
|
327
|
-
set align(value: string) {
|
|
319
|
+
public set align(value: string) {
|
|
328
320
|
if (value !== this._align && (value === 'left' || value === 'center' || value === 'right')) {
|
|
329
321
|
this._align = value;
|
|
330
322
|
this.updateText();
|
|
@@ -335,7 +327,7 @@ export class BitmapText extends DisplayObject {
|
|
|
335
327
|
* Gets the tint color of this bitmap text.
|
|
336
328
|
* @returns {number} The current tint color in RGB format.
|
|
337
329
|
*/
|
|
338
|
-
get tint() {
|
|
330
|
+
public get tint() {
|
|
339
331
|
return this._tint;
|
|
340
332
|
}
|
|
341
333
|
|
|
@@ -343,7 +335,7 @@ export class BitmapText extends DisplayObject {
|
|
|
343
335
|
* Sets the tint color of this bitmap text.
|
|
344
336
|
* @param {number} value - The new tint color in RGB format.
|
|
345
337
|
*/
|
|
346
|
-
set tint(value: number) {
|
|
338
|
+
public set tint(value: number) {
|
|
347
339
|
if (value !== this._tint) {
|
|
348
340
|
this._tint = value;
|
|
349
341
|
this.updateText();
|
|
@@ -354,7 +346,7 @@ export class BitmapText extends DisplayObject {
|
|
|
354
346
|
* Gets the fill color of this bitmap text as a hex string.
|
|
355
347
|
* @returns {string} The current fill color in hex format.
|
|
356
348
|
*/
|
|
357
|
-
get fill() {
|
|
349
|
+
public get fill() {
|
|
358
350
|
if (typeof this.tint === 'number') {
|
|
359
351
|
let colorStr = this.tint.toString(16);
|
|
360
352
|
while (colorStr.length < 6) {
|
|
@@ -369,7 +361,7 @@ export class BitmapText extends DisplayObject {
|
|
|
369
361
|
* Sets the fill color of this bitmap text.
|
|
370
362
|
* @param {string} value - The new fill color in hex format or CSS color name.
|
|
371
363
|
*/
|
|
372
|
-
set fill(value: string) {
|
|
364
|
+
public set fill(value: string) {
|
|
373
365
|
this.tint = typeof value === 'string' ? Number.parseInt(value.replace('#', ''), 16) : value;
|
|
374
366
|
}
|
|
375
367
|
|
|
@@ -377,7 +369,7 @@ export class BitmapText extends DisplayObject {
|
|
|
377
369
|
* Gets the font key used by this bitmap text.
|
|
378
370
|
* @returns {string} The current font key.
|
|
379
371
|
*/
|
|
380
|
-
get font() {
|
|
372
|
+
public get font() {
|
|
381
373
|
return this._font;
|
|
382
374
|
}
|
|
383
375
|
|
|
@@ -385,7 +377,7 @@ export class BitmapText extends DisplayObject {
|
|
|
385
377
|
* Sets the font key used by this bitmap text.
|
|
386
378
|
* @param {string} value - The new font key to use.
|
|
387
379
|
*/
|
|
388
|
-
set font(value: string) {
|
|
380
|
+
public set font(value: string) {
|
|
389
381
|
const trimmedValue = value.trim();
|
|
390
382
|
if (trimmedValue !== this._font) {
|
|
391
383
|
this._font = trimmedValue;
|
|
@@ -398,7 +390,7 @@ export class BitmapText extends DisplayObject {
|
|
|
398
390
|
* Gets the font size of this bitmap text.
|
|
399
391
|
* @returns {number} The current font size.
|
|
400
392
|
*/
|
|
401
|
-
get fontSize(): number {
|
|
393
|
+
public get fontSize(): number {
|
|
402
394
|
return this._fontSize;
|
|
403
395
|
}
|
|
404
396
|
|
|
@@ -406,8 +398,8 @@ export class BitmapText extends DisplayObject {
|
|
|
406
398
|
* Sets the font size of this bitmap text.
|
|
407
399
|
* @param {number} value - The new font size to use.
|
|
408
400
|
*/
|
|
409
|
-
set fontSize(value: any) {
|
|
410
|
-
value =
|
|
401
|
+
public set fontSize(value: any) {
|
|
402
|
+
value = Math.trunc(Number(value));
|
|
411
403
|
if (value !== this._fontSize && value > 0) {
|
|
412
404
|
this._fontSize = value;
|
|
413
405
|
this.updateText();
|
|
@@ -418,7 +410,7 @@ export class BitmapText extends DisplayObject {
|
|
|
418
410
|
* Gets the text content of this bitmap text.
|
|
419
411
|
* @returns {string} The current text content.
|
|
420
412
|
*/
|
|
421
|
-
get text(): string {
|
|
413
|
+
public get text(): string {
|
|
422
414
|
return this._text;
|
|
423
415
|
}
|
|
424
416
|
|
|
@@ -426,7 +418,7 @@ export class BitmapText extends DisplayObject {
|
|
|
426
418
|
* Sets the text content of this bitmap text.
|
|
427
419
|
* @param {string | number | boolean | Date} value - The new text content to set.
|
|
428
420
|
*/
|
|
429
|
-
set text(value: string | number | boolean | Date) {
|
|
421
|
+
public set text(value: string | number | boolean | Date) {
|
|
430
422
|
const typedValue = value.toString();
|
|
431
423
|
if (typedValue !== this._text) {
|
|
432
424
|
this._text = typedValue || '';
|
|
@@ -438,7 +430,7 @@ export class BitmapText extends DisplayObject {
|
|
|
438
430
|
* Gets the maximum width of this bitmap text.
|
|
439
431
|
* @returns {number} The current maximum width.
|
|
440
432
|
*/
|
|
441
|
-
get maxWidth() {
|
|
433
|
+
public get maxWidth() {
|
|
442
434
|
return this._maxWidth;
|
|
443
435
|
}
|
|
444
436
|
|
|
@@ -446,7 +438,7 @@ export class BitmapText extends DisplayObject {
|
|
|
446
438
|
* Sets the maximum width of this bitmap text.
|
|
447
439
|
* @param {number} value - The new maximum width to set.
|
|
448
440
|
*/
|
|
449
|
-
set maxWidth(value: number) {
|
|
441
|
+
public set maxWidth(value: number) {
|
|
450
442
|
if (value !== this._maxWidth) {
|
|
451
443
|
this._maxWidth = value;
|
|
452
444
|
this.updateText();
|
|
@@ -457,7 +449,7 @@ export class BitmapText extends DisplayObject {
|
|
|
457
449
|
* Gets whether smoothing is enabled for this bitmap text's font.
|
|
458
450
|
* @returns {boolean} True if smoothing is enabled, false otherwise.
|
|
459
451
|
*/
|
|
460
|
-
get smoothed() {
|
|
452
|
+
public get smoothed() {
|
|
461
453
|
return !this._data.base.scaleMode;
|
|
462
454
|
}
|
|
463
455
|
|
|
@@ -465,7 +457,7 @@ export class BitmapText extends DisplayObject {
|
|
|
465
457
|
* Sets whether smoothing is enabled for this bitmap text's font.
|
|
466
458
|
* @param {boolean} value - Whether to enable smoothing (true) or not (false).
|
|
467
459
|
*/
|
|
468
|
-
set smoothed(value: boolean) {
|
|
460
|
+
public set smoothed(value: boolean) {
|
|
469
461
|
if (value) {
|
|
470
462
|
this._data.base.scaleMode = SCALE_LINEAR;
|
|
471
463
|
} else {
|
|
@@ -2,6 +2,7 @@ import { BUTTON, POINTER_CONTACT } from '../core/const.js';
|
|
|
2
2
|
import { InputHandler } from '../core/input_handler.js';
|
|
3
3
|
import { Signal } from '../core/signal.js';
|
|
4
4
|
import { Image } from './image.js';
|
|
5
|
+
import type { Game } from '../core/game.js';
|
|
5
6
|
|
|
6
7
|
const STATE_OVER = 'Over';
|
|
7
8
|
const STATE_OUT = 'Out';
|
|
@@ -11,23 +12,23 @@ const STATE_DISABLED = 'Disabled';
|
|
|
11
12
|
|
|
12
13
|
export class Button extends Image {
|
|
13
14
|
[key: `_on${string}Frame`]: string | null;
|
|
14
|
-
_onOverFrame!: string | null;
|
|
15
|
-
_onOutFrame!: string | null;
|
|
16
|
-
_onDownFrame!: string | null;
|
|
17
|
-
_onUpFrame!: string | null;
|
|
18
|
-
_onDisabledFrame!: string | null;
|
|
19
|
-
onInputOver!: Signal;
|
|
20
|
-
onInputOut!: Signal;
|
|
21
|
-
onInputDown!: Signal;
|
|
22
|
-
onInputUp!: Signal;
|
|
23
|
-
onOverMouseOnly!: boolean;
|
|
24
|
-
justReleasedPreventsOver!: number;
|
|
25
|
-
freezeFrames!: boolean;
|
|
26
|
-
forceOut!: any;
|
|
27
|
-
input!: InputHandler;
|
|
15
|
+
public _onOverFrame!: string | null;
|
|
16
|
+
public _onOutFrame!: string | null;
|
|
17
|
+
public _onDownFrame!: string | null;
|
|
18
|
+
public _onUpFrame!: string | null;
|
|
19
|
+
public _onDisabledFrame!: string | null;
|
|
20
|
+
public onInputOver!: Signal;
|
|
21
|
+
public onInputOut!: Signal;
|
|
22
|
+
public onInputDown!: Signal;
|
|
23
|
+
public onInputUp!: Signal;
|
|
24
|
+
public onOverMouseOnly!: boolean;
|
|
25
|
+
public justReleasedPreventsOver!: number;
|
|
26
|
+
public freezeFrames!: boolean;
|
|
27
|
+
public forceOut!: any;
|
|
28
|
+
public input!: InputHandler;
|
|
28
29
|
/**
|
|
29
30
|
* Creates a new Button instance.
|
|
30
|
-
* @param {
|
|
31
|
+
* @param {Game} game - The game instance this button belongs to.
|
|
31
32
|
* @param {number} x - The x position of the button.
|
|
32
33
|
* @param {number} y - The y position of the button.
|
|
33
34
|
* @param {string} key - The texture key to use for the button.
|
|
@@ -39,10 +40,10 @@ export class Button extends Image {
|
|
|
39
40
|
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
40
41
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
41
42
|
*/
|
|
42
|
-
constructor(
|
|
43
|
-
game:
|
|
44
|
-
x
|
|
45
|
-
y
|
|
43
|
+
public constructor(
|
|
44
|
+
game: Game,
|
|
45
|
+
x = 0,
|
|
46
|
+
y = 0,
|
|
46
47
|
key: string | null = null,
|
|
47
48
|
callback: Function | null = null,
|
|
48
49
|
callbackContext: any | null = null,
|
|
@@ -84,7 +85,7 @@ export class Button extends Image {
|
|
|
84
85
|
/**
|
|
85
86
|
* Destroys this button and cleans up resources.
|
|
86
87
|
*/
|
|
87
|
-
override destroy() {
|
|
88
|
+
public override destroy() {
|
|
88
89
|
this._onOverFrame = null;
|
|
89
90
|
this._onOutFrame = null;
|
|
90
91
|
this._onDownFrame = null;
|
|
@@ -112,7 +113,7 @@ export class Button extends Image {
|
|
|
112
113
|
* @param {boolean} isEnabled - Whether the button should be enabled (true) or disabled (false).
|
|
113
114
|
* @param {boolean} isImmediate - Whether to change the state immediately or with a delay (default: false).
|
|
114
115
|
*/
|
|
115
|
-
setEnabled(isEnabled: boolean, isImmediate
|
|
116
|
+
public setEnabled(isEnabled: boolean, isImmediate = false) {
|
|
116
117
|
this.input.enabled = isEnabled;
|
|
117
118
|
if (isImmediate) {
|
|
118
119
|
this.changeStateFrame(isEnabled ? STATE_UP : STATE_DISABLED);
|
|
@@ -126,14 +127,14 @@ export class Button extends Image {
|
|
|
126
127
|
/**
|
|
127
128
|
* Clears all the frame settings for this button.
|
|
128
129
|
*/
|
|
129
|
-
clearFrames() {
|
|
130
|
+
public clearFrames() {
|
|
130
131
|
this.setFrames(null, null, null, null, null);
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
/**
|
|
134
135
|
* Called when this button is removed from the world.
|
|
135
136
|
*/
|
|
136
|
-
removedFromWorld() {
|
|
137
|
+
public removedFromWorld() {
|
|
137
138
|
this.inputEnabled = false;
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -143,7 +144,7 @@ export class Button extends Image {
|
|
|
143
144
|
* @param {string} frame - The frame identifier to set for this state.
|
|
144
145
|
* @param {boolean} switchImmediately - Whether to switch to the new frame immediately (default: false).
|
|
145
146
|
*/
|
|
146
|
-
setStateFrame(state: string, frame: string | null, switchImmediately
|
|
147
|
+
public setStateFrame(state: string, frame: string | null, switchImmediately = false) {
|
|
147
148
|
const frameKey: `_on${string}Frame` = `_on${state}Frame`;
|
|
148
149
|
if (frame) {
|
|
149
150
|
this[frameKey] = frame;
|
|
@@ -160,7 +161,7 @@ export class Button extends Image {
|
|
|
160
161
|
* @param {string} newState - The new state to change to (Over, Out, Down, Up, Disabled).
|
|
161
162
|
* @returns {boolean} True if the frame was changed, false otherwise.
|
|
162
163
|
*/
|
|
163
|
-
changeStateFrame(newState: string) {
|
|
164
|
+
public changeStateFrame(newState: string) {
|
|
164
165
|
if (this.freezeFrames) {
|
|
165
166
|
return false;
|
|
166
167
|
}
|
|
@@ -185,7 +186,7 @@ export class Button extends Image {
|
|
|
185
186
|
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
186
187
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
187
188
|
*/
|
|
188
|
-
setFrames(
|
|
189
|
+
public setFrames(
|
|
189
190
|
overFrame: string | null,
|
|
190
191
|
outFrame: string | null,
|
|
191
192
|
downFrame: string | null,
|
|
@@ -206,7 +207,7 @@ export class Button extends Image {
|
|
|
206
207
|
* @param {object} _sprite - The sprite that triggered the event.
|
|
207
208
|
* @param {object} pointer - The pointer that triggered the event.
|
|
208
209
|
*/
|
|
209
|
-
onInputOverHandler(_sprite: any, pointer: any) {
|
|
210
|
+
public onInputOverHandler(_sprite: any, pointer: any) {
|
|
210
211
|
if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
|
|
211
212
|
// If the Pointer was only just released then we don't fire an over event
|
|
212
213
|
return;
|
|
@@ -225,7 +226,7 @@ export class Button extends Image {
|
|
|
225
226
|
* @param {object} _sprite - The sprite that triggered the event.
|
|
226
227
|
* @param {object} pointer - The pointer that triggered the event.
|
|
227
228
|
*/
|
|
228
|
-
onInputOutHandler(_sprite: any, pointer: any) {
|
|
229
|
+
public onInputOutHandler(_sprite: any, pointer: any) {
|
|
229
230
|
this.changeStateFrame(STATE_OUT);
|
|
230
231
|
if (this.onInputOut) {
|
|
231
232
|
this.onInputOut.dispatch(this, pointer);
|
|
@@ -237,7 +238,7 @@ export class Button extends Image {
|
|
|
237
238
|
* @param {object} _sprite - The sprite that triggered the event.
|
|
238
239
|
* @param {object} pointer - The pointer that triggered the event.
|
|
239
240
|
*/
|
|
240
|
-
onInputDownHandler(_sprite: any, pointer: any) {
|
|
241
|
+
public onInputDownHandler(_sprite: any, pointer: any) {
|
|
241
242
|
this.changeStateFrame(STATE_DOWN);
|
|
242
243
|
if (this.onInputDown) {
|
|
243
244
|
this.onInputDown.dispatch(this, pointer);
|
|
@@ -250,7 +251,7 @@ export class Button extends Image {
|
|
|
250
251
|
* @param {object} pointer - The pointer that triggered the event.
|
|
251
252
|
* @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
|
|
252
253
|
*/
|
|
253
|
-
onInputUpHandler(_sprite: any, pointer: any, isOver: boolean) {
|
|
254
|
+
public onInputUpHandler(_sprite: any, pointer: any, isOver: boolean) {
|
|
254
255
|
if (this.onInputUp) {
|
|
255
256
|
this.onInputUp.dispatch(this, pointer, isOver);
|
|
256
257
|
}
|
|
@@ -276,7 +277,7 @@ export class Button extends Image {
|
|
|
276
277
|
* Gets whether input is currently enabled for this button.
|
|
277
278
|
* @returns {boolean} True if input is enabled, false otherwise.
|
|
278
279
|
*/
|
|
279
|
-
get inputEnabled() {
|
|
280
|
+
public get inputEnabled() {
|
|
280
281
|
return this.input && this.input.enabled;
|
|
281
282
|
}
|
|
282
283
|
|
|
@@ -284,7 +285,7 @@ export class Button extends Image {
|
|
|
284
285
|
* Sets whether input is currently enabled for this button.
|
|
285
286
|
* @param {boolean} value - Whether to enable (true) or disable (false) input.
|
|
286
287
|
*/
|
|
287
|
-
set inputEnabled(value: boolean) {
|
|
288
|
+
public set inputEnabled(value: boolean) {
|
|
288
289
|
if (value) {
|
|
289
290
|
if (this.input === null) {
|
|
290
291
|
this.input = new InputHandler(this);
|