@vpmedia/phaser 1.95.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 +29 -0
- package/package.json +9 -9
- package/src/phaser/core/animation.js +61 -56
- package/src/phaser/core/animation_manager.js +55 -55
- 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 +34 -18
- package/src/phaser/core/loader.js +170 -170
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- 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 +30 -30
- package/src/phaser/core/timer.js +64 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +90 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +29 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +61 -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 +16 -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 +112 -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 +50 -50
- package/src/phaser/display/image.js +54 -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 +212 -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 +20 -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 +69 -69
- package/src/phaser/geom/ellipse.js +28 -28
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -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 +61 -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/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +43 -43
- 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 +52 -19
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +170 -170
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +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 +30 -30
- package/types/phaser/core/timer.d.ts +64 -64
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +90 -90
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +29 -24
- 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 +59 -52
- 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/renderer.d.ts +16 -16
- 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 +101 -101
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +47 -47
- package/types/phaser/display/image.d.ts +42 -40
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +207 -184
- 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 +9 -9
- 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_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +20 -20
- 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/geom/circle.d.ts +69 -69
- package/types/phaser/geom/ellipse.d.ts +28 -28
- package/types/phaser/geom/line.d.ts +93 -93
- package/types/phaser/geom/matrix.d.ts +54 -54
- package/types/phaser/geom/point.d.ts +96 -96
- package/types/phaser/geom/polygon.d.ts +22 -22
- package/types/phaser/geom/rectangle.d.ts +132 -132
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/pnpm-workspace.yaml +0 -4
package/src/phaser/core/tween.js
CHANGED
|
@@ -5,10 +5,10 @@ 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;
|
|
@@ -54,15 +54,15 @@ export class Tween {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {object} properties -
|
|
59
|
-
* @param {number} duration -
|
|
60
|
-
* @param {string | Function} ease -
|
|
61
|
-
* @param {boolean} autoStart -
|
|
62
|
-
* @param {number} delay -
|
|
63
|
-
* @param {number} repeat -
|
|
64
|
-
* @param {boolean} yoyo -
|
|
65
|
-
* @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.
|
|
66
66
|
*/
|
|
67
67
|
to(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
68
68
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -80,15 +80,15 @@ export class Tween {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {object} properties -
|
|
85
|
-
* @param {number} duration -
|
|
86
|
-
* @param {string | Function} ease -
|
|
87
|
-
* @param {boolean} autoStart -
|
|
88
|
-
* @param {number} delay -
|
|
89
|
-
* @param {number} repeat -
|
|
90
|
-
* @param {boolean} yoyo -
|
|
91
|
-
* @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.
|
|
92
92
|
*/
|
|
93
93
|
from(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
|
|
94
94
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -107,9 +107,9 @@ export class Tween {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {number} index -
|
|
112
|
-
* @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.
|
|
113
113
|
*/
|
|
114
114
|
start(index = 0) {
|
|
115
115
|
if (this.game === null || this.target === null || this.timeline.length === 0 || this.isRunning) {
|
|
@@ -142,9 +142,9 @@ export class Tween {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param {boolean} complete -
|
|
147
|
-
* @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.
|
|
148
148
|
*/
|
|
149
149
|
stop(complete = false) {
|
|
150
150
|
this.isRunning = false;
|
|
@@ -162,11 +162,11 @@ export class Tween {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
|
-
*
|
|
166
|
-
* @param {string} property -
|
|
167
|
-
* @param {object} value -
|
|
168
|
-
* @param {number} index -
|
|
169
|
-
* @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.
|
|
170
170
|
*/
|
|
171
171
|
updateTweenData(property, value, index = 0) {
|
|
172
172
|
if (this.timeline.length === 0) {
|
|
@@ -183,21 +183,21 @@ export class Tween {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
*
|
|
187
|
-
* @param {number} duration -
|
|
188
|
-
* @param {number} index -
|
|
189
|
-
* @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.
|
|
190
190
|
*/
|
|
191
191
|
delay(duration, index) {
|
|
192
192
|
return this.updateTweenData('delay', duration, index);
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
197
|
-
* @param {number} total -
|
|
198
|
-
* @param {number} repeatDelay -
|
|
199
|
-
* @param {number} index -
|
|
200
|
-
* @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.
|
|
201
201
|
*/
|
|
202
202
|
repeat(total, repeatDelay = 0, index = 0) {
|
|
203
203
|
this.updateTweenData('repeatCounter', total, index);
|
|
@@ -205,21 +205,21 @@ export class Tween {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
209
|
-
* @param {number} duration -
|
|
210
|
-
* @param {number} index -
|
|
211
|
-
* @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.
|
|
212
212
|
*/
|
|
213
213
|
repeatDelay(duration, index) {
|
|
214
214
|
return this.updateTweenData('repeatDelay', duration, index);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
219
|
-
* @param {boolean} enable -
|
|
220
|
-
* @param {number} yoyoDelay -
|
|
221
|
-
* @param {number} index -
|
|
222
|
-
* @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.
|
|
223
223
|
*/
|
|
224
224
|
yoyo(enable, yoyoDelay = 0, index = 0) {
|
|
225
225
|
this.updateTweenData('yoyo', enable, index);
|
|
@@ -227,20 +227,20 @@ export class Tween {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
|
-
*
|
|
231
|
-
* @param {number} duration -
|
|
232
|
-
* @param {number} index -
|
|
233
|
-
* @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.
|
|
234
234
|
*/
|
|
235
235
|
yoyoDelay(duration, index) {
|
|
236
236
|
return this.updateTweenData('yoyoDelay', duration, index);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
/**
|
|
240
|
-
*
|
|
241
|
-
* @param {string|Function} ease -
|
|
242
|
-
* @param {number} index -
|
|
243
|
-
* @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.
|
|
244
244
|
*/
|
|
245
245
|
easing(ease, index) {
|
|
246
246
|
if (typeof ease === 'string' && this.manager.easeMap[ease]) {
|
|
@@ -250,11 +250,11 @@ export class Tween {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
*
|
|
254
|
-
* @param {Function} interpolation -
|
|
255
|
-
* @param {object} context -
|
|
256
|
-
* @param {number} index -
|
|
257
|
-
* @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.
|
|
258
258
|
*/
|
|
259
259
|
interpolation(interpolation, context = MathUtils, index = 0) {
|
|
260
260
|
this.updateTweenData('interpolationFunction', interpolation, index);
|
|
@@ -262,9 +262,9 @@ export class Tween {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
|
-
*
|
|
266
|
-
* @param {number} total -
|
|
267
|
-
* @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.
|
|
268
268
|
*/
|
|
269
269
|
repeatAll(total = 0) {
|
|
270
270
|
this.repeatCounter = total;
|
|
@@ -272,9 +272,9 @@ export class Tween {
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
/**
|
|
275
|
-
*
|
|
276
|
-
* @param {...any} args -
|
|
277
|
-
* @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.
|
|
278
278
|
*/
|
|
279
279
|
chain(...args) {
|
|
280
280
|
let i = args.length;
|
|
@@ -290,9 +290,9 @@ export class Tween {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
|
-
*
|
|
294
|
-
* @param {boolean} value -
|
|
295
|
-
* @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.
|
|
296
296
|
*/
|
|
297
297
|
loop(value = true) {
|
|
298
298
|
this.repeatCounter = value ? -1 : 0;
|
|
@@ -300,10 +300,10 @@ export class Tween {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param {Function} callback -
|
|
305
|
-
* @param {object} callbackContext -
|
|
306
|
-
* @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.
|
|
307
307
|
*/
|
|
308
308
|
onUpdateCallback(callback, callbackContext) {
|
|
309
309
|
this._onUpdateCallback = callback;
|
|
@@ -312,7 +312,7 @@ export class Tween {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
|
-
*
|
|
315
|
+
* Pauses the tween.
|
|
316
316
|
*/
|
|
317
317
|
pause() {
|
|
318
318
|
this.isPaused = true;
|
|
@@ -321,7 +321,7 @@ export class Tween {
|
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
324
|
+
* Internal method to pause the tween.
|
|
325
325
|
*/
|
|
326
326
|
_pause() {
|
|
327
327
|
if (!this._codePaused) {
|
|
@@ -331,7 +331,7 @@ export class Tween {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* Resumes the tween.
|
|
335
335
|
*/
|
|
336
336
|
resume() {
|
|
337
337
|
if (this.isPaused) {
|
|
@@ -346,7 +346,7 @@ export class Tween {
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
|
-
*
|
|
349
|
+
* Internal method to resume the tween.
|
|
350
350
|
*/
|
|
351
351
|
_resume() {
|
|
352
352
|
if (!this._codePaused) {
|
|
@@ -355,9 +355,9 @@ export class Tween {
|
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
/**
|
|
358
|
-
*
|
|
359
|
-
* @param {number} time -
|
|
360
|
-
* @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.
|
|
361
361
|
*/
|
|
362
362
|
update(time) {
|
|
363
363
|
if (this.pendingDelete || !this.target) {
|
|
@@ -438,10 +438,10 @@ export class Tween {
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
/**
|
|
441
|
-
*
|
|
442
|
-
* @param {number} frameRate -
|
|
443
|
-
* @param {object[]} data -
|
|
444
|
-
* @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.
|
|
445
445
|
*/
|
|
446
446
|
generateData(frameRate = 60, data = []) {
|
|
447
447
|
if (this.game === null || this.target === null) {
|
|
@@ -470,8 +470,8 @@ export class Tween {
|
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
/**
|
|
473
|
-
*
|
|
474
|
-
* @returns {number}
|
|
473
|
+
* Gets the total duration of all timeline entries.
|
|
474
|
+
* @returns {number} The total duration in milliseconds.
|
|
475
475
|
*/
|
|
476
476
|
get totalDuration() {
|
|
477
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,8 +36,8 @@ 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;
|
|
@@ -95,15 +95,16 @@ export class TweenManager {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
99
|
-
* @returns {Tween[]}
|
|
98
|
+
* Get all tweens managed by this manager.
|
|
99
|
+
* @returns {Tween[]} An array of all active tweens.
|
|
100
100
|
*/
|
|
101
101
|
getAll() {
|
|
102
102
|
return this._tweens;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* Remove all tweens from the manager.
|
|
107
|
+
* This method removes all active and pending tweens.
|
|
107
108
|
*/
|
|
108
109
|
removeAll() {
|
|
109
110
|
for (let i = 0; i < this._tweens.length; i += 1) {
|
|
@@ -113,9 +114,9 @@ export class TweenManager {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
/**
|
|
116
|
-
*
|
|
117
|
-
* @param {object} obj -
|
|
118
|
-
* @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.
|
|
119
120
|
*/
|
|
120
121
|
removeFrom(obj, children = null) {
|
|
121
122
|
let i;
|
|
@@ -143,8 +144,8 @@ export class TweenManager {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {Tween} tween -
|
|
147
|
+
* Add a tween to the manager.
|
|
148
|
+
* @param {Tween} tween - The tween to add.
|
|
148
149
|
*/
|
|
149
150
|
add(tween) {
|
|
150
151
|
tween.manager = this;
|
|
@@ -152,17 +153,17 @@ export class TweenManager {
|
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
/**
|
|
155
|
-
*
|
|
156
|
-
* @param {object} object -
|
|
157
|
-
* @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.
|
|
158
159
|
*/
|
|
159
160
|
create(object) {
|
|
160
161
|
return new Tween(object, this.game, this);
|
|
161
162
|
}
|
|
162
163
|
|
|
163
164
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @param {Tween | null | undefined} tween -
|
|
165
|
+
* Remove a tween from the manager.
|
|
166
|
+
* @param {Tween | null | undefined} tween - The tween to remove.
|
|
166
167
|
*/
|
|
167
168
|
remove(tween) {
|
|
168
169
|
let i = this._tweens.indexOf(tween);
|
|
@@ -177,8 +178,8 @@ export class TweenManager {
|
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @returns {boolean}
|
|
181
|
+
* Update all tweens managed by this manager.
|
|
182
|
+
* @returns {boolean} True if any tweens were updated, false otherwise.
|
|
182
183
|
*/
|
|
183
184
|
update() {
|
|
184
185
|
const addTweens = this._add.length;
|
|
@@ -204,16 +205,17 @@ export class TweenManager {
|
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {object} object -
|
|
209
|
-
* @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.
|
|
210
211
|
*/
|
|
211
212
|
isTweening(object) {
|
|
212
213
|
return this._tweens.some((tween) => tween.target === object);
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
/**
|
|
216
|
-
*
|
|
217
|
+
* Pause all tweens managed by this manager.
|
|
218
|
+
* This method pauses all active tweens.
|
|
217
219
|
*/
|
|
218
220
|
_pauseAll() {
|
|
219
221
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -222,7 +224,8 @@ export class TweenManager {
|
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
/**
|
|
225
|
-
*
|
|
227
|
+
* Resume all tweens managed by this manager.
|
|
228
|
+
* This method resumes all paused tweens.
|
|
226
229
|
*/
|
|
227
230
|
_resumeAll() {
|
|
228
231
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -231,7 +234,8 @@ export class TweenManager {
|
|
|
231
234
|
}
|
|
232
235
|
|
|
233
236
|
/**
|
|
234
|
-
*
|
|
237
|
+
* Pause all tweens managed by this manager.
|
|
238
|
+
* This method pauses all active tweens.
|
|
235
239
|
*/
|
|
236
240
|
pauseAll() {
|
|
237
241
|
for (let i = this._tweens.length - 1; i >= 0; i -= 1) {
|
|
@@ -240,7 +244,8 @@ export class TweenManager {
|
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
/**
|
|
243
|
-
*
|
|
247
|
+
* Resume all tweens managed by this manager.
|
|
248
|
+
* This method resumes all paused tweens.
|
|
244
249
|
*/
|
|
245
250
|
resumeAll() {
|
|
246
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);
|