@vpmedia/phaser 1.94.0 → 1.96.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/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
package/src/phaser/core/tween.js
CHANGED
|
@@ -5,48 +5,64 @@ import { TweenData } from './tween_data.js';
|
|
|
5
5
|
|
|
6
6
|
export class Tween {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {import('../display/display_object.js').DisplayObject} target -
|
|
10
|
-
* @param {import('./game.js').Game} game -
|
|
11
|
-
* @param {import('./tween_manager.js').TweenManager} manager -
|
|
8
|
+
* Creates a new Tween instance.
|
|
9
|
+
* @param {import('../display/display_object.js').DisplayObject} target - The object to tween.
|
|
10
|
+
* @param {import('./game.js').Game} game - Reference to the Phaser Game instance.
|
|
11
|
+
* @param {import('./tween_manager.js').TweenManager} manager - Reference to the Tween Manager.
|
|
12
12
|
*/
|
|
13
13
|
constructor(target, game, manager) {
|
|
14
14
|
this.game = game;
|
|
15
15
|
this.target = target;
|
|
16
|
+
/** @type {import('./tween_manager.js').TweenManager} */
|
|
16
17
|
this.manager = manager;
|
|
17
18
|
/** @type {TweenData[]} */
|
|
18
19
|
this.timeline = [];
|
|
20
|
+
/** @type {boolean} */
|
|
19
21
|
this.reverse = false;
|
|
22
|
+
/** @type {number} */
|
|
20
23
|
this.timeScale = 1;
|
|
24
|
+
/** @type {number} */
|
|
21
25
|
this.repeatCounter = 0;
|
|
26
|
+
/** @type {boolean} */
|
|
22
27
|
this.pendingDelete = false;
|
|
28
|
+
/** @type {Signal} */
|
|
23
29
|
this.onStart = new Signal();
|
|
30
|
+
/** @type {Signal} */
|
|
24
31
|
this.onLoop = new Signal();
|
|
32
|
+
/** @type {Signal} */
|
|
25
33
|
this.onRepeat = new Signal();
|
|
34
|
+
/** @type {Signal} */
|
|
26
35
|
this.onChildComplete = new Signal();
|
|
36
|
+
/** @type {Signal} */
|
|
27
37
|
this.onComplete = new Signal();
|
|
38
|
+
/** @type {boolean} */
|
|
28
39
|
this.isRunning = false;
|
|
40
|
+
/** @type {number} */
|
|
29
41
|
this.current = 0;
|
|
30
42
|
this.properties = {};
|
|
31
43
|
this.chainedTween = null;
|
|
44
|
+
/** @type {boolean} */
|
|
32
45
|
this.isPaused = false;
|
|
33
46
|
this._onUpdateCallback = null;
|
|
34
47
|
this._onUpdateCallbackContext = null;
|
|
48
|
+
/** @type {number} */
|
|
35
49
|
this._pausedTime = 0;
|
|
50
|
+
/** @type {boolean} */
|
|
36
51
|
this._codePaused = false;
|
|
52
|
+
/** @type {boolean} */
|
|
37
53
|
this._hasStarted = false;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
56
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param {object} properties -
|
|
43
|
-
* @param {number} duration -
|
|
44
|
-
* @param {string | Function} ease -
|
|
45
|
-
* @param {boolean} autoStart -
|
|
46
|
-
* @param {number} delay -
|
|
47
|
-
* @param {number} repeat -
|
|
48
|
-
* @param {boolean} yoyo -
|
|
49
|
-
* @returns {Tween}
|
|
57
|
+
* Adds a tween to the timeline that animates properties to their target values.
|
|
58
|
+
* @param {object} properties - The properties to tween and their target values.
|
|
59
|
+
* @param {number} duration - The duration of the tween in milliseconds.
|
|
60
|
+
* @param {string | Function} ease - The easing function to use.
|
|
61
|
+
* @param {boolean} autoStart - Whether to start the tween immediately.
|
|
62
|
+
* @param {number} delay - The delay before starting the tween in milliseconds.
|
|
63
|
+
* @param {number} repeat - Number of times to repeat the tween.
|
|
64
|
+
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
65
|
+
* @returns {Tween} This Tween object for chaining.
|
|
50
66
|
*/
|
|
51
67
|
to(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
52
68
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -64,15 +80,15 @@ export class Tween {
|
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
/**
|
|
67
|
-
*
|
|
68
|
-
* @param {object} properties -
|
|
69
|
-
* @param {number} duration -
|
|
70
|
-
* @param {string | Function} ease -
|
|
71
|
-
* @param {boolean} autoStart -
|
|
72
|
-
* @param {number} delay -
|
|
73
|
-
* @param {number} repeat -
|
|
74
|
-
* @param {boolean} yoyo -
|
|
75
|
-
* @returns {Tween}
|
|
83
|
+
* Adds a tween to the timeline that animates properties from their current values.
|
|
84
|
+
* @param {object} properties - The properties to tween and their target values.
|
|
85
|
+
* @param {number} duration - The duration of the tween in milliseconds.
|
|
86
|
+
* @param {string | Function} ease - The easing function to use.
|
|
87
|
+
* @param {boolean} autoStart - Whether to start the tween immediately.
|
|
88
|
+
* @param {number} delay - The delay before starting the tween in milliseconds.
|
|
89
|
+
* @param {number} repeat - Number of times to repeat the tween.
|
|
90
|
+
* @param {boolean} yoyo - Whether to reverse the tween on repeat.
|
|
91
|
+
* @returns {Tween} This Tween object for chaining.
|
|
76
92
|
*/
|
|
77
93
|
from(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
78
94
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -91,9 +107,9 @@ export class Tween {
|
|
|
91
107
|
}
|
|
92
108
|
|
|
93
109
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {number} index -
|
|
96
|
-
* @returns {Tween}
|
|
110
|
+
* Starts the tween timeline from a specific index.
|
|
111
|
+
* @param {number} index - The index to start from in the timeline.
|
|
112
|
+
* @returns {Tween} This Tween object for chaining.
|
|
97
113
|
*/
|
|
98
114
|
start(index = 0) {
|
|
99
115
|
if (this.game === null || this.target === null || this.timeline.length === 0 || this.isRunning) {
|
|
@@ -126,9 +142,9 @@ export class Tween {
|
|
|
126
142
|
}
|
|
127
143
|
|
|
128
144
|
/**
|
|
129
|
-
*
|
|
130
|
-
* @param {boolean} complete -
|
|
131
|
-
* @returns {Tween}
|
|
145
|
+
* Stops the tween and optionally completes it.
|
|
146
|
+
* @param {boolean} complete - Whether to dispatch the complete event.
|
|
147
|
+
* @returns {Tween} This Tween object for chaining.
|
|
132
148
|
*/
|
|
133
149
|
stop(complete = false) {
|
|
134
150
|
this.isRunning = false;
|
|
@@ -146,11 +162,11 @@ export class Tween {
|
|
|
146
162
|
}
|
|
147
163
|
|
|
148
164
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @param {string} property -
|
|
151
|
-
* @param {object} value -
|
|
152
|
-
* @param {number} index -
|
|
153
|
-
* @returns {Tween}
|
|
165
|
+
* Updates a property in the tween data.
|
|
166
|
+
* @param {string} property - The property name to update.
|
|
167
|
+
* @param {object} value - The new value for the property.
|
|
168
|
+
* @param {number} index - The index in the timeline to update.
|
|
169
|
+
* @returns {Tween} This Tween object for chaining.
|
|
154
170
|
*/
|
|
155
171
|
updateTweenData(property, value, index = 0) {
|
|
156
172
|
if (this.timeline.length === 0) {
|
|
@@ -167,21 +183,21 @@ export class Tween {
|
|
|
167
183
|
}
|
|
168
184
|
|
|
169
185
|
/**
|
|
170
|
-
*
|
|
171
|
-
* @param {number} duration -
|
|
172
|
-
* @param {number} index -
|
|
173
|
-
* @returns {Tween}
|
|
186
|
+
* Sets a delay for a specific timeline entry.
|
|
187
|
+
* @param {number} duration - The delay in milliseconds.
|
|
188
|
+
* @param {number} index - The index in the timeline to apply the delay to.
|
|
189
|
+
* @returns {Tween} This Tween object for chaining.
|
|
174
190
|
*/
|
|
175
191
|
delay(duration, index) {
|
|
176
192
|
return this.updateTweenData('delay', duration, index);
|
|
177
193
|
}
|
|
178
194
|
|
|
179
195
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @param {number} total -
|
|
182
|
-
* @param {number} repeatDelay -
|
|
183
|
-
* @param {number} index -
|
|
184
|
-
* @returns {Tween}
|
|
196
|
+
* Sets how many times to repeat the tween.
|
|
197
|
+
* @param {number} total - The number of times to repeat (-1 for infinite).
|
|
198
|
+
* @param {number} repeatDelay - Delay between repeats in milliseconds.
|
|
199
|
+
* @param {number} index - The index in the timeline to apply the repeat to.
|
|
200
|
+
* @returns {Tween} This Tween object for chaining.
|
|
185
201
|
*/
|
|
186
202
|
repeat(total, repeatDelay = 0, index = 0) {
|
|
187
203
|
this.updateTweenData('repeatCounter', total, index);
|
|
@@ -189,21 +205,21 @@ export class Tween {
|
|
|
189
205
|
}
|
|
190
206
|
|
|
191
207
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {number} duration -
|
|
194
|
-
* @param {number} index -
|
|
195
|
-
* @returns {Tween}
|
|
208
|
+
* Sets the repeat delay for a specific timeline entry.
|
|
209
|
+
* @param {number} duration - The delay between repeats in milliseconds.
|
|
210
|
+
* @param {number} index - The index in the timeline to apply the delay to.
|
|
211
|
+
* @returns {Tween} This Tween object for chaining.
|
|
196
212
|
*/
|
|
197
213
|
repeatDelay(duration, index) {
|
|
198
214
|
return this.updateTweenData('repeatDelay', duration, index);
|
|
199
215
|
}
|
|
200
216
|
|
|
201
217
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param {boolean} enable -
|
|
204
|
-
* @param {number} yoyoDelay -
|
|
205
|
-
* @param {number} index -
|
|
206
|
-
* @returns {Tween}
|
|
218
|
+
* Enables or disables yoyo behavior for a timeline entry.
|
|
219
|
+
* @param {boolean} enable - Whether to enable yoyo behavior.
|
|
220
|
+
* @param {number} yoyoDelay - Delay between yoyo cycles in milliseconds.
|
|
221
|
+
* @param {number} index - The index in the timeline to apply yoyo to.
|
|
222
|
+
* @returns {Tween} This Tween object for chaining.
|
|
207
223
|
*/
|
|
208
224
|
yoyo(enable, yoyoDelay = 0, index = 0) {
|
|
209
225
|
this.updateTweenData('yoyo', enable, index);
|
|
@@ -211,20 +227,20 @@ export class Tween {
|
|
|
211
227
|
}
|
|
212
228
|
|
|
213
229
|
/**
|
|
214
|
-
*
|
|
215
|
-
* @param {number} duration -
|
|
216
|
-
* @param {number} index -
|
|
217
|
-
* @returns {Tween}
|
|
230
|
+
* Sets the yoyo delay for a specific timeline entry.
|
|
231
|
+
* @param {number} duration - The delay between yoyo cycles in milliseconds.
|
|
232
|
+
* @param {number} index - The index in the timeline to apply the delay to.
|
|
233
|
+
* @returns {Tween} This Tween object for chaining.
|
|
218
234
|
*/
|
|
219
235
|
yoyoDelay(duration, index) {
|
|
220
236
|
return this.updateTweenData('yoyoDelay', duration, index);
|
|
221
237
|
}
|
|
222
238
|
|
|
223
239
|
/**
|
|
224
|
-
*
|
|
225
|
-
* @param {string|Function} ease -
|
|
226
|
-
* @param {number} index -
|
|
227
|
-
* @returns {Tween}
|
|
240
|
+
* Sets the easing function for a timeline entry.
|
|
241
|
+
* @param {string|Function} ease - The easing function to use.
|
|
242
|
+
* @param {number} index - The index in the timeline to apply easing to.
|
|
243
|
+
* @returns {Tween} This Tween object for chaining.
|
|
228
244
|
*/
|
|
229
245
|
easing(ease, index) {
|
|
230
246
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -234,11 +250,11 @@ export class Tween {
|
|
|
234
250
|
}
|
|
235
251
|
|
|
236
252
|
/**
|
|
237
|
-
*
|
|
238
|
-
* @param {Function} interpolation -
|
|
239
|
-
* @param {object} context -
|
|
240
|
-
* @param {number} index -
|
|
241
|
-
* @returns {Tween}
|
|
253
|
+
* Sets the interpolation function for a timeline entry.
|
|
254
|
+
* @param {Function} interpolation - The interpolation function to use.
|
|
255
|
+
* @param {object} context - The context in which to call the interpolation function.
|
|
256
|
+
* @param {number} index - The index in the timeline to apply interpolation to.
|
|
257
|
+
* @returns {Tween} This Tween object for chaining.
|
|
242
258
|
*/
|
|
243
259
|
interpolation(interpolation, context = MathUtils, index = 0) {
|
|
244
260
|
this.updateTweenData('interpolationFunction', interpolation, index);
|
|
@@ -246,9 +262,9 @@ export class Tween {
|
|
|
246
262
|
}
|
|
247
263
|
|
|
248
264
|
/**
|
|
249
|
-
*
|
|
250
|
-
* @param {number} total -
|
|
251
|
-
* @returns {Tween}
|
|
265
|
+
* Sets how many times to repeat all timeline entries.
|
|
266
|
+
* @param {number} total - The number of times to repeat (-1 for infinite).
|
|
267
|
+
* @returns {Tween} This Tween object for chaining.
|
|
252
268
|
*/
|
|
253
269
|
repeatAll(total = 0) {
|
|
254
270
|
this.repeatCounter = total;
|
|
@@ -256,9 +272,9 @@ export class Tween {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
/**
|
|
259
|
-
*
|
|
260
|
-
* @param {...any} args -
|
|
261
|
-
* @returns {Tween}
|
|
275
|
+
* Chains one or more tweens to this tween.
|
|
276
|
+
* @param {...any} args - The tweens to chain.
|
|
277
|
+
* @returns {Tween} This Tween object for chaining.
|
|
262
278
|
*/
|
|
263
279
|
chain(...args) {
|
|
264
280
|
let i = args.length;
|
|
@@ -274,9 +290,9 @@ export class Tween {
|
|
|
274
290
|
}
|
|
275
291
|
|
|
276
292
|
/**
|
|
277
|
-
*
|
|
278
|
-
* @param {boolean} value -
|
|
279
|
-
* @returns {Tween}
|
|
293
|
+
* Sets whether the tween should loop infinitely.
|
|
294
|
+
* @param {boolean} value - Whether to loop infinitely.
|
|
295
|
+
* @returns {Tween} This Tween object for chaining.
|
|
280
296
|
*/
|
|
281
297
|
loop(value = true) {
|
|
282
298
|
this.repeatCounter = value ? -1 : 0;
|
|
@@ -284,10 +300,10 @@ export class Tween {
|
|
|
284
300
|
}
|
|
285
301
|
|
|
286
302
|
/**
|
|
287
|
-
*
|
|
288
|
-
* @param {Function} callback -
|
|
289
|
-
* @param {object} callbackContext -
|
|
290
|
-
* @returns {Tween}
|
|
303
|
+
* Sets a callback to be called when the tween updates.
|
|
304
|
+
* @param {Function} callback - The callback function to call.
|
|
305
|
+
* @param {object} callbackContext - The context in which to call the callback.
|
|
306
|
+
* @returns {Tween} This Tween object for chaining.
|
|
291
307
|
*/
|
|
292
308
|
onUpdateCallback(callback, callbackContext) {
|
|
293
309
|
this._onUpdateCallback = callback;
|
|
@@ -296,7 +312,7 @@ export class Tween {
|
|
|
296
312
|
}
|
|
297
313
|
|
|
298
314
|
/**
|
|
299
|
-
*
|
|
315
|
+
* Pauses the tween.
|
|
300
316
|
*/
|
|
301
317
|
pause() {
|
|
302
318
|
this.isPaused = true;
|
|
@@ -305,7 +321,7 @@ export class Tween {
|
|
|
305
321
|
}
|
|
306
322
|
|
|
307
323
|
/**
|
|
308
|
-
*
|
|
324
|
+
* Internal method to pause the tween.
|
|
309
325
|
*/
|
|
310
326
|
_pause() {
|
|
311
327
|
if (!this._codePaused) {
|
|
@@ -315,7 +331,7 @@ export class Tween {
|
|
|
315
331
|
}
|
|
316
332
|
|
|
317
333
|
/**
|
|
318
|
-
*
|
|
334
|
+
* Resumes the tween.
|
|
319
335
|
*/
|
|
320
336
|
resume() {
|
|
321
337
|
if (this.isPaused) {
|
|
@@ -330,7 +346,7 @@ export class Tween {
|
|
|
330
346
|
}
|
|
331
347
|
|
|
332
348
|
/**
|
|
333
|
-
*
|
|
349
|
+
* Internal method to resume the tween.
|
|
334
350
|
*/
|
|
335
351
|
_resume() {
|
|
336
352
|
if (!this._codePaused) {
|
|
@@ -339,9 +355,9 @@ export class Tween {
|
|
|
339
355
|
}
|
|
340
356
|
|
|
341
357
|
/**
|
|
342
|
-
*
|
|
343
|
-
* @param {number} time -
|
|
344
|
-
* @returns {boolean}
|
|
358
|
+
* Updates the tween state at a given time.
|
|
359
|
+
* @param {number} time - The current game time.
|
|
360
|
+
* @returns {boolean} True if the tween should continue running, false if it's complete.
|
|
345
361
|
*/
|
|
346
362
|
update(time) {
|
|
347
363
|
if (this.pendingDelete || !this.target) {
|
|
@@ -422,10 +438,10 @@ export class Tween {
|
|
|
422
438
|
}
|
|
423
439
|
|
|
424
440
|
/**
|
|
425
|
-
*
|
|
426
|
-
* @param {number} frameRate -
|
|
427
|
-
* @param {object[]} data -
|
|
428
|
-
* @returns {object[]}
|
|
441
|
+
* Generates animation data for a given frame rate.
|
|
442
|
+
* @param {number} frameRate - The target frame rate.
|
|
443
|
+
* @param {object[]} data - The array to store the generated data in.
|
|
444
|
+
* @returns {object[]} The populated data array.
|
|
429
445
|
*/
|
|
430
446
|
generateData(frameRate = 60, data = []) {
|
|
431
447
|
if (this.game === null || this.target === null) {
|
|
@@ -454,8 +470,8 @@ export class Tween {
|
|
|
454
470
|
}
|
|
455
471
|
|
|
456
472
|
/**
|
|
457
|
-
*
|
|
458
|
-
* @returns {number}
|
|
473
|
+
* Gets the total duration of all timeline entries.
|
|
474
|
+
* @returns {number} The total duration in milliseconds.
|
|
459
475
|
*/
|
|
460
476
|
get totalDuration() {
|
|
461
477
|
let total = 0;
|
|
@@ -3,8 +3,8 @@ import { TWEEN_COMPLETE, TWEEN_LOOPED, TWEEN_PENDING, TWEEN_RUNNING } from './co
|
|
|
3
3
|
|
|
4
4
|
export class TweenData {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {import('./tween.js').Tween} parent -
|
|
6
|
+
* Creates a new TweenData instance.
|
|
7
|
+
* @param {import('./tween.js').Tween} parent - The parent Tween instance.
|
|
8
8
|
*/
|
|
9
9
|
constructor(parent) {
|
|
10
10
|
this.parent = parent;
|
|
@@ -34,14 +34,14 @@ export class TweenData {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param {object} properties -
|
|
39
|
-
* @param {number} duration -
|
|
40
|
-
* @param {(number) => number} ease -
|
|
41
|
-
* @param {number} delay -
|
|
42
|
-
* @param {number} repeat -
|
|
43
|
-
* @param {boolean} yoyo -
|
|
44
|
-
* @returns {TweenData}
|
|
37
|
+
* Sets the target properties to tween to.
|
|
38
|
+
* @param {object} properties - The properties to tween to.
|
|
39
|
+
* @param {number} duration - The duration of the tween in milliseconds.
|
|
40
|
+
* @param {(number) => number} ease - The easing function to use.
|
|
41
|
+
* @param {number} delay - The delay before starting the tween in milliseconds.
|
|
42
|
+
* @param {number} repeat - The number of times to repeat the tween (0 = no repeat, -1 = infinite).
|
|
43
|
+
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
44
|
+
* @returns {TweenData} This TweenData object for chaining.
|
|
45
45
|
*/
|
|
46
46
|
to(properties, duration, ease, delay, repeat, yoyo) {
|
|
47
47
|
this.vEnd = properties;
|
|
@@ -55,14 +55,14 @@ export class TweenData {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {object} properties -
|
|
60
|
-
* @param {number} duration -
|
|
61
|
-
* @param {(number) => number} ease -
|
|
62
|
-
* @param {number} delay -
|
|
63
|
-
* @param {number} repeat -
|
|
64
|
-
* @param {boolean} yoyo -
|
|
65
|
-
* @returns {TweenData}
|
|
58
|
+
* Sets the target properties to tween from (in reverse).
|
|
59
|
+
* @param {object} properties - The properties to tween from.
|
|
60
|
+
* @param {number} duration - The duration of the tween in milliseconds.
|
|
61
|
+
* @param {(number) => number} ease - The easing function to use.
|
|
62
|
+
* @param {number} delay - The delay before starting the tween in milliseconds.
|
|
63
|
+
* @param {number} repeat - The number of times to repeat the tween (0 = no repeat, -1 = infinite).
|
|
64
|
+
* @param {boolean} yoyo - Whether to reverse the tween on each repeat.
|
|
65
|
+
* @returns {TweenData} This TweenData object for chaining.
|
|
66
66
|
*/
|
|
67
67
|
from(properties, duration, ease, delay, repeat, yoyo) {
|
|
68
68
|
this.vEnd = properties;
|
|
@@ -76,8 +76,8 @@ export class TweenData {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
* @returns {TweenData}
|
|
79
|
+
* Starts the tween.
|
|
80
|
+
* @returns {TweenData} This TweenData object for chaining.
|
|
81
81
|
*/
|
|
82
82
|
start() {
|
|
83
83
|
this.startTime = this.game.time.time + this.delay;
|
|
@@ -108,8 +108,8 @@ export class TweenData {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @returns {TweenData}
|
|
111
|
+
* Loads the tween values from the parent object.
|
|
112
|
+
* @returns {TweenData} This TweenData object for chaining.
|
|
113
113
|
*/
|
|
114
114
|
loadValues() {
|
|
115
115
|
const keys = Object.keys(this.parent.properties);
|
|
@@ -145,9 +145,9 @@ export class TweenData {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
149
|
-
* @param {number} time -
|
|
150
|
-
* @returns {number}
|
|
148
|
+
* Updates the tween at a given time.
|
|
149
|
+
* @param {number} time - The current time in milliseconds.
|
|
150
|
+
* @returns {number} The tween status (TWEEN_PENDING, TWEEN_RUNNING, or TWEEN_COMPLETE).
|
|
151
151
|
*/
|
|
152
152
|
update(time) {
|
|
153
153
|
if (!this.isRunning) {
|
|
@@ -188,9 +188,9 @@ export class TweenData {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
192
|
-
* @param {number} frameRate -
|
|
193
|
-
* @returns {object[]}
|
|
191
|
+
* Generates an array of tween data points for a given frame rate.
|
|
192
|
+
* @param {number} frameRate - The frame rate to generate data for.
|
|
193
|
+
* @returns {object[]} An array of tween data points.
|
|
194
194
|
*/
|
|
195
195
|
generateData(frameRate) {
|
|
196
196
|
if (this.parent.reverse) {
|
|
@@ -237,8 +237,8 @@ export class TweenData {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
|
-
*
|
|
241
|
-
* @returns {number}
|
|
240
|
+
* Handles tween repetition logic.
|
|
241
|
+
* @returns {number} The tween status (TWEEN_LOOPED or TWEEN_COMPLETE).
|
|
242
242
|
*/
|
|
243
243
|
repeat() {
|
|
244
244
|
// If not a yoyo and repeatCounter = 0 then we're done
|
|
@@ -36,13 +36,16 @@ import {
|
|
|
36
36
|
|
|
37
37
|
export class TweenManager {
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @param {import('./game.js').Game} game -
|
|
39
|
+
* Creates a new TweenManager instance.
|
|
40
|
+
* @param {import('./game.js').Game} game - The game instance this manager belongs to.
|
|
41
41
|
*/
|
|
42
42
|
constructor(game) {
|
|
43
43
|
this.game = game;
|
|
44
|
+
/** @type {Tween[]} */
|
|
44
45
|
this._tweens = [];
|
|
46
|
+
/** @type {Tween[]} */
|
|
45
47
|
this._add = [];
|
|
48
|
+
/** @type {{[key: string]: (k: number) => number}} */
|
|
46
49
|
this.easeMap = {
|
|
47
50
|
Linear: LinearNone,
|
|
48
51
|
Quad: QuadraticOut,
|
|
@@ -92,15 +95,16 @@ export class TweenManager {
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @returns {Tween[]}
|
|
98
|
+
* Get all tweens managed by this manager.
|
|
99
|
+
* @returns {Tween[]} An array of all active tweens.
|
|
97
100
|
*/
|
|
98
101
|
getAll() {
|
|
99
102
|
return this._tweens;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
/**
|
|
103
|
-
*
|
|
106
|
+
* Remove all tweens from the manager.
|
|
107
|
+
* This method removes all active and pending tweens.
|
|
104
108
|
*/
|
|
105
109
|
removeAll() {
|
|
106
110
|
for (let i = 0; i < this._tweens.length; i += 1) {
|
|
@@ -110,9 +114,9 @@ export class TweenManager {
|
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/**
|
|
113
|
-
*
|
|
114
|
-
* @param {object} obj -
|
|
115
|
-
* @param {object[]} children -
|
|
117
|
+
* Remove tweens associated with an object or its children.
|
|
118
|
+
* @param {object} obj - The object to remove tweens from.
|
|
119
|
+
* @param {object[]} children - Optional array of child objects to remove tweens from.
|
|
116
120
|
*/
|
|
117
121
|
removeFrom(obj, children = null) {
|
|
118
122
|
let i;
|
|
@@ -140,8 +144,8 @@ export class TweenManager {
|
|
|
140
144
|
}
|
|
141
145
|
|
|
142
146
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @param {Tween} tween -
|
|
147
|
+
* Add a tween to the manager.
|
|
148
|
+
* @param {Tween} tween - The tween to add.
|
|
145
149
|
*/
|
|
146
150
|
add(tween) {
|
|
147
151
|
tween.manager = this;
|
|
@@ -149,17 +153,17 @@ export class TweenManager {
|
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @param {object} object -
|
|
154
|
-
* @returns {Tween}
|
|
156
|
+
* Create a new tween for an object.
|
|
157
|
+
* @param {object} object - The object to create a tween for.
|
|
158
|
+
* @returns {Tween} The created Tween object.
|
|
155
159
|
*/
|
|
156
160
|
create(object) {
|
|
157
161
|
return new Tween(object, this.game, this);
|
|
158
162
|
}
|
|
159
163
|
|
|
160
164
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param {Tween | null | undefined} tween -
|
|
165
|
+
* Remove a tween from the manager.
|
|
166
|
+
* @param {Tween | null | undefined} tween - The tween to remove.
|
|
163
167
|
*/
|
|
164
168
|
remove(tween) {
|
|
165
169
|
let i = this._tweens.indexOf(tween);
|
|
@@ -174,8 +178,8 @@ export class TweenManager {
|
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
/**
|
|
177
|
-
*
|
|
178
|
-
* @returns {boolean}
|
|
181
|
+
* Update all tweens managed by this manager.
|
|
182
|
+
* @returns {boolean} True if any tweens were updated, false otherwise.
|
|
179
183
|
*/
|
|
180
184
|
update() {
|
|
181
185
|
const addTweens = this._add.length;
|
|
@@ -201,16 +205,17 @@ export class TweenManager {
|
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
/**
|
|
204
|
-
*
|
|
205
|
-
* @param {object} object -
|
|
206
|
-
* @returns {boolean}
|
|
208
|
+
* Check if an object is currently being tweened.
|
|
209
|
+
* @param {object} object - The object to check.
|
|
210
|
+
* @returns {boolean} True if the object is being tweened, false otherwise.
|
|
207
211
|
*/
|
|
208
212
|
isTweening(object) {
|
|
209
213
|
return this._tweens.some((tween) => tween.target === object);
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
/**
|
|
213
|
-
*
|
|
217
|
+
* Pause all tweens managed by this manager.
|
|
218
|
+
* This method pauses all active tweens.
|
|
214
219
|
*/
|
|
215
220
|
_pauseAll() {
|
|
216
221
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -219,7 +224,8 @@ export class TweenManager {
|
|
|
219
224
|
}
|
|
220
225
|
|
|
221
226
|
/**
|
|
222
|
-
*
|
|
227
|
+
* Resume all tweens managed by this manager.
|
|
228
|
+
* This method resumes all paused tweens.
|
|
223
229
|
*/
|
|
224
230
|
_resumeAll() {
|
|
225
231
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -228,7 +234,8 @@ export class TweenManager {
|
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
/**
|
|
231
|
-
*
|
|
237
|
+
* Pause all tweens managed by this manager.
|
|
238
|
+
* This method pauses all active tweens.
|
|
232
239
|
*/
|
|
233
240
|
pauseAll() {
|
|
234
241
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -237,7 +244,8 @@ export class TweenManager {
|
|
|
237
244
|
}
|
|
238
245
|
|
|
239
246
|
/**
|
|
240
|
-
*
|
|
247
|
+
* Resume all tweens managed by this manager.
|
|
248
|
+
* This method resumes all paused tweens.
|
|
241
249
|
*/
|
|
242
250
|
resumeAll() {
|
|
243
251
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
package/src/phaser/core/world.js
CHANGED
|
@@ -2,15 +2,16 @@ import { Group } from '../display/group.js';
|
|
|
2
2
|
|
|
3
3
|
export class World extends Group {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {import('./game.js').Game} game -
|
|
5
|
+
* Creates a new World instance.
|
|
6
|
+
* @param {import('./game.js').Game} game - The game instance this world belongs to.
|
|
7
7
|
*/
|
|
8
8
|
constructor(game) {
|
|
9
9
|
super(game, null, '__world', false);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Initialize the world.
|
|
14
|
+
* This method is called when the game boots and sets up the world.
|
|
14
15
|
*/
|
|
15
16
|
boot() {
|
|
16
17
|
this.game.stage.addChild(this);
|