@vpmedia/phaser 1.103.0 → 1.105.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 +997 -403
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -11
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +20 -10
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +3 -3
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +68 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts +10 -10
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +6 -5
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +49 -158
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +8 -7
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts +27 -48
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +11 -58
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts +4 -14
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +50 -3
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +66 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +64 -20
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +26 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +18 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +53 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +19 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +56 -28
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +2 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +77 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +25 -9
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +9 -8
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +2 -2
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +58 -10
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +28 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +10 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +7 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +32 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +30 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -12
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +38 -14
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +30 -5
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +8 -4
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +35 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +24 -8
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +6 -2
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +18 -5
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -3
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +9 -9
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +82 -23
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +42 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +11 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +24 -9
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +36 -13
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +86 -66
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +8 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +5 -2
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +10 -10
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +17 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +7 -2
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +11 -10
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +11 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +12 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +25 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +35 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +6 -6
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +11 -10
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +6 -5
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +14 -14
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +13 -12
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts +19 -19
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +6 -6
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +20 -20
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +9 -7
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +19 -19
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +2 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +17 -15
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts +51 -142
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/phaser/core/animation.ts +41 -18
- package/src/phaser/core/animation_manager.ts +21 -12
- package/src/phaser/core/animation_parser.ts +11 -3
- package/src/phaser/core/array_set.ts +8 -8
- package/src/phaser/core/cache.ts +75 -60
- package/src/phaser/core/device.ts +23 -1
- package/src/phaser/core/device_util.ts +10 -10
- package/src/phaser/core/dom.ts +5 -5
- package/src/phaser/core/event_manager.ts +52 -177
- package/src/phaser/core/factory.ts +25 -17
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -74
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +40 -11
- package/src/phaser/core/input.ts +68 -17
- package/src/phaser/core/input_handler.ts +81 -45
- package/src/phaser/core/input_mouse.ts +42 -13
- package/src/phaser/core/input_mspointer.ts +24 -9
- package/src/phaser/core/input_pointer.ts +55 -12
- package/src/phaser/core/input_touch.ts +26 -9
- package/src/phaser/core/loader.ts +97 -42
- package/src/phaser/core/loader_parser.ts +6 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -27
- package/src/phaser/core/scene.ts +3 -2
- package/src/phaser/core/scene_manager.ts +26 -11
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +72 -26
- package/src/phaser/core/sound_manager.ts +31 -13
- package/src/phaser/core/sound_sprite.ts +10 -5
- package/src/phaser/core/stage.ts +8 -4
- package/src/phaser/core/time.ts +33 -7
- package/src/phaser/core/timer.ts +40 -14
- package/src/phaser/core/timer_event.ts +23 -14
- package/src/phaser/core/tween.ts +43 -23
- package/src/phaser/core/tween_data.ts +31 -7
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -7
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -18
- package/src/phaser/display/button.ts +24 -23
- package/src/phaser/display/canvas/buffer.ts +6 -3
- package/src/phaser/display/canvas/graphics.ts +3 -4
- package/src/phaser/display/canvas/masker.ts +2 -3
- package/src/phaser/display/canvas/pool.ts +3 -4
- package/src/phaser/display/canvas/renderer.ts +19 -7
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +9 -9
- package/src/phaser/display/display_object.ts +120 -61
- package/src/phaser/display/graphics.ts +56 -25
- package/src/phaser/display/graphics_data.ts +11 -2
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -14
- package/src/phaser/display/image.ts +37 -19
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +5 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -2
- package/src/phaser/display/webgl/base_texture.ts +14 -3
- package/src/phaser/display/webgl/blend_manager.ts +5 -3
- package/src/phaser/display/webgl/earcut.ts +27 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -4
- package/src/phaser/display/webgl/filter_manager.ts +5 -2
- package/src/phaser/display/webgl/filter_texture.ts +7 -3
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -2
- package/src/phaser/display/webgl/renderer.ts +24 -7
- package/src/phaser/display/webgl/shader/complex.ts +7 -2
- package/src/phaser/display/webgl/shader/fast.ts +8 -2
- package/src/phaser/display/webgl/shader/normal.ts +12 -2
- package/src/phaser/display/webgl/shader/primitive.ts +7 -2
- package/src/phaser/display/webgl/shader/strip.ts +7 -2
- package/src/phaser/display/webgl/shader_manager.ts +13 -3
- package/src/phaser/display/webgl/sprite_batch.ts +20 -4
- package/src/phaser/display/webgl/stencil_manager.ts +8 -5
- package/src/phaser/display/webgl/texture.ts +35 -4
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +6 -6
- package/src/phaser/geom/circle.ts +10 -10
- package/src/phaser/geom/ellipse.ts +6 -6
- package/src/phaser/geom/line.ts +14 -14
- package/src/phaser/geom/matrix.ts +12 -12
- package/src/phaser/geom/point.ts +19 -19
- package/src/phaser/geom/polygon.ts +5 -5
- package/src/phaser/geom/rectangle.ts +21 -21
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +5 -5
- package/src/phaser/geom/util/matrix.ts +1 -1
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +15 -15
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.ts +65 -151
|
@@ -1,7 +1,29 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Signal } from './signal.js';
|
|
3
2
|
|
|
4
3
|
export class Animation {
|
|
4
|
+
game!: import('./game.js').Game;
|
|
5
|
+
_parent!: import('../display/image.js').Image;
|
|
6
|
+
_frameData!: import('./frame_data.js').FrameData;
|
|
7
|
+
name!: string;
|
|
8
|
+
_frames!: any;
|
|
9
|
+
delay!: number;
|
|
10
|
+
loop!: boolean;
|
|
11
|
+
loopCount!: number;
|
|
12
|
+
isFinished!: boolean;
|
|
13
|
+
isPlaying!: boolean;
|
|
14
|
+
isPaused!: boolean;
|
|
15
|
+
_pauseStartTime!: number;
|
|
16
|
+
_frameIndex!: number;
|
|
17
|
+
_frameDiff!: number;
|
|
18
|
+
_frameSkip!: number;
|
|
19
|
+
currentFrame!: import('./frame.js').Frame;
|
|
20
|
+
onStart!: Signal;
|
|
21
|
+
onUpdate!: Signal | null;
|
|
22
|
+
onComplete!: Signal;
|
|
23
|
+
onLoop!: Signal;
|
|
24
|
+
isReversed!: boolean;
|
|
25
|
+
_timeLastFrame!: number;
|
|
26
|
+
_timeNextFrame!: number;
|
|
5
27
|
/**
|
|
6
28
|
* Creates a new Animation instance.
|
|
7
29
|
* @param {import('./game.js').Game} game - The game instance this animation belongs to.
|
|
@@ -12,7 +34,7 @@ export class Animation {
|
|
|
12
34
|
* @param {number} frameRate - The frame rate at which this animation should play (frames per second).
|
|
13
35
|
* @param {boolean} loop - Whether the animation should loop when it completes.
|
|
14
36
|
*/
|
|
15
|
-
constructor(game, parent, name, frameData, frames, frameRate, loop = false) {
|
|
37
|
+
constructor(game: import('./game.js').Game, parent: import('../display/image.js').Image, name: string, frameData: import('./frame_data.js').FrameData, frames: string[]|number[], frameRate: number, loop: boolean = false) {
|
|
16
38
|
/** @type {import('./game.js').Game} */
|
|
17
39
|
this.game = game;
|
|
18
40
|
this._parent = parent;
|
|
@@ -64,7 +86,7 @@ export class Animation {
|
|
|
64
86
|
* @param {boolean} loop - Whether to loop this animation (if null, uses the original loop setting).
|
|
65
87
|
* @returns {Animation} This Animation instance for chaining.
|
|
66
88
|
*/
|
|
67
|
-
play(frameRate = null, loop = null) {
|
|
89
|
+
play(frameRate: number = null, loop: boolean = null) {
|
|
68
90
|
if (typeof frameRate === 'number') {
|
|
69
91
|
// If they set a new frame rate then use it, otherwise use the one set on creation
|
|
70
92
|
this.delay = 1000 / frameRate;
|
|
@@ -121,7 +143,8 @@ export class Animation {
|
|
|
121
143
|
*/
|
|
122
144
|
reverseOnce() {
|
|
123
145
|
this.onComplete.addOnce(this.reverse, this);
|
|
124
|
-
|
|
146
|
+
this.reverse();
|
|
147
|
+
return this;
|
|
125
148
|
}
|
|
126
149
|
|
|
127
150
|
/**
|
|
@@ -129,7 +152,7 @@ export class Animation {
|
|
|
129
152
|
* @param {string|number} frameId - The identifier (name or index) of the frame to set.
|
|
130
153
|
* @param {boolean} useLocalFrameIndex - If true, treats frameId as an index into the local frames array.
|
|
131
154
|
*/
|
|
132
|
-
setFrame(frameId, useLocalFrameIndex = false) {
|
|
155
|
+
setFrame(frameId: string|number, useLocalFrameIndex: boolean = false) {
|
|
133
156
|
let frameIndex;
|
|
134
157
|
// Find the index to the desired frame.
|
|
135
158
|
if (typeof frameId === 'string') {
|
|
@@ -163,7 +186,7 @@ export class Animation {
|
|
|
163
186
|
* @param {boolean} resetFrame - If true, resets to the first frame.
|
|
164
187
|
* @param {boolean} dispatchComplete - If true, dispatches the onComplete signal.
|
|
165
188
|
*/
|
|
166
|
-
stop(resetFrame = false, dispatchComplete = false) {
|
|
189
|
+
stop(resetFrame: boolean = false, dispatchComplete: boolean = false) {
|
|
167
190
|
this.isPlaying = false;
|
|
168
191
|
this.isFinished = true;
|
|
169
192
|
this.paused = false;
|
|
@@ -243,7 +266,7 @@ export class Animation {
|
|
|
243
266
|
if (this.onUpdate) {
|
|
244
267
|
this.onUpdate.dispatch(this, this.currentFrame);
|
|
245
268
|
// False if the animation was destroyed from within a callback
|
|
246
|
-
return
|
|
269
|
+
return Boolean(this._frameData);
|
|
247
270
|
}
|
|
248
271
|
return true;
|
|
249
272
|
}
|
|
@@ -262,7 +285,7 @@ export class Animation {
|
|
|
262
285
|
* @param {boolean} fromPlay - Whether this call is from play().
|
|
263
286
|
* @returns {boolean} True if the frame was updated, false otherwise.
|
|
264
287
|
*/
|
|
265
|
-
updateCurrentFrame(signalUpdate, fromPlay = false) {
|
|
288
|
+
updateCurrentFrame(signalUpdate: boolean, fromPlay: boolean = false) {
|
|
266
289
|
if (!this._frameData || !this.currentFrame) {
|
|
267
290
|
// The animation is already destroyed, probably from a callback
|
|
268
291
|
return false;
|
|
@@ -276,7 +299,7 @@ export class Animation {
|
|
|
276
299
|
if (this.onUpdate && signalUpdate) {
|
|
277
300
|
this.onUpdate.dispatch(this, this.currentFrame);
|
|
278
301
|
// False if the animation was destroyed from within a callback
|
|
279
|
-
return
|
|
302
|
+
return Boolean(this._frameData);
|
|
280
303
|
}
|
|
281
304
|
return true;
|
|
282
305
|
}
|
|
@@ -285,7 +308,7 @@ export class Animation {
|
|
|
285
308
|
* Advances the animation to the next frame(s).
|
|
286
309
|
* @param {number} quantity - The number of frames to advance by.
|
|
287
310
|
*/
|
|
288
|
-
next(quantity = 1) {
|
|
311
|
+
next(quantity: number = 1) {
|
|
289
312
|
let frame = this._frameIndex + quantity;
|
|
290
313
|
if (frame >= this._frames.length) {
|
|
291
314
|
if (this.loop) {
|
|
@@ -304,7 +327,7 @@ export class Animation {
|
|
|
304
327
|
* Moves the animation to the previous frame(s).
|
|
305
328
|
* @param {number} quantity - The number of frames to move back by.
|
|
306
329
|
*/
|
|
307
|
-
previous(quantity = 1) {
|
|
330
|
+
previous(quantity: number = 1) {
|
|
308
331
|
let frame = this._frameIndex - quantity;
|
|
309
332
|
if (frame < 0) {
|
|
310
333
|
if (this.loop) {
|
|
@@ -323,7 +346,7 @@ export class Animation {
|
|
|
323
346
|
* Updates the frame data used by this animation.
|
|
324
347
|
* @param {import('./frame_data.js').FrameData} frameData - The new FrameData object to use.
|
|
325
348
|
*/
|
|
326
|
-
updateFrameData(frameData) {
|
|
349
|
+
updateFrameData(frameData: import('./frame_data.js').FrameData) {
|
|
327
350
|
this._frameData = frameData;
|
|
328
351
|
this.currentFrame = this._frameData
|
|
329
352
|
? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length])
|
|
@@ -379,7 +402,7 @@ export class Animation {
|
|
|
379
402
|
* Sets whether this animation is currently paused.
|
|
380
403
|
* @param {boolean} value - True to pause the animation, false to resume it.
|
|
381
404
|
*/
|
|
382
|
-
set paused(value) {
|
|
405
|
+
set paused(value: boolean) {
|
|
383
406
|
this.isPaused = value;
|
|
384
407
|
if (value) {
|
|
385
408
|
this._pauseStartTime = this.game.time.time;
|
|
@@ -400,7 +423,7 @@ export class Animation {
|
|
|
400
423
|
* Sets whether this animation is currently reversed.
|
|
401
424
|
* @param {boolean} value - True to reverse the animation, false to normal direction.
|
|
402
425
|
*/
|
|
403
|
-
set reversed(value) {
|
|
426
|
+
set reversed(value: boolean) {
|
|
404
427
|
this.isReversed = value;
|
|
405
428
|
}
|
|
406
429
|
|
|
@@ -427,7 +450,7 @@ export class Animation {
|
|
|
427
450
|
* Sets the current frame index.
|
|
428
451
|
* @param {number} value - The new frame index to set.
|
|
429
452
|
*/
|
|
430
|
-
set frame(value) {
|
|
453
|
+
set frame(value: number) {
|
|
431
454
|
this.currentFrame = this._frameData.getFrame(this._frames[value]);
|
|
432
455
|
if (this.currentFrame !== null) {
|
|
433
456
|
this._frameIndex = value;
|
|
@@ -450,7 +473,7 @@ export class Animation {
|
|
|
450
473
|
* Sets the animation speed (frame rate).
|
|
451
474
|
* @param {number} value - The new frame rate in frames per second.
|
|
452
475
|
*/
|
|
453
|
-
set speed(value) {
|
|
476
|
+
set speed(value: number) {
|
|
454
477
|
if (value > 0) {
|
|
455
478
|
this.delay = 1000 / value;
|
|
456
479
|
}
|
|
@@ -468,7 +491,7 @@ export class Animation {
|
|
|
468
491
|
* Sets whether the update signal is enabled.
|
|
469
492
|
* @param {boolean} value - True to enable the update signal, false to disable it.
|
|
470
493
|
*/
|
|
471
|
-
set enableUpdate(value) {
|
|
494
|
+
set enableUpdate(value: boolean) {
|
|
472
495
|
if (value && this.onUpdate === null) {
|
|
473
496
|
this.onUpdate = new Signal();
|
|
474
497
|
} else if (!value && this.onUpdate !== null) {
|
|
@@ -476,4 +499,4 @@ export class Animation {
|
|
|
476
499
|
this.onUpdate = null;
|
|
477
500
|
}
|
|
478
501
|
}
|
|
479
|
-
}
|
|
502
|
+
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Animation } from './animation.js';
|
|
3
2
|
import { ENGINE_ERROR_CANNOT_SET_FRAME, ENGINE_ERROR_CANNOT_SET_FRAME_NAME } from './error_code.js';
|
|
4
3
|
|
|
5
4
|
export class AnimationManager {
|
|
5
|
+
sprite!: any;
|
|
6
|
+
game!: any;
|
|
7
|
+
currentFrame!: any;
|
|
8
|
+
currentAnim!: any;
|
|
9
|
+
updateIfVisible!: any;
|
|
10
|
+
isLoaded!: any;
|
|
11
|
+
_frameData!: any;
|
|
12
|
+
_anims!: any;
|
|
13
|
+
_outputFrames!: any;
|
|
14
|
+
_frameIndex!: any;
|
|
6
15
|
/**
|
|
7
16
|
* Creates a new AnimationManager instance.
|
|
8
17
|
* @param {import('../display/image.js').Image} sprite - Reference to the parent Sprite.
|
|
9
18
|
*/
|
|
10
|
-
constructor(sprite) {
|
|
19
|
+
constructor(sprite: import('../display/image.js').Image) {
|
|
11
20
|
this.sprite = sprite;
|
|
12
21
|
this.game = sprite.game;
|
|
13
22
|
/** @type {import('./frame.js').Frame} */
|
|
@@ -47,7 +56,7 @@ export class AnimationManager {
|
|
|
47
56
|
* @param {string|number} frame - The frame index or name to set as current.
|
|
48
57
|
* @returns {boolean} True if the frame data was loaded successfully, false otherwise.
|
|
49
58
|
*/
|
|
50
|
-
loadFrameData(frameData, frame) {
|
|
59
|
+
loadFrameData(frameData: import('./frame_data.js').FrameData, frame: string|number) {
|
|
51
60
|
if (!frameData) {
|
|
52
61
|
return false;
|
|
53
62
|
}
|
|
@@ -77,7 +86,7 @@ export class AnimationManager {
|
|
|
77
86
|
* @param {string|number} frame - The frame index or name to set as current.
|
|
78
87
|
* @returns {boolean} True if the frame data was copied successfully, false otherwise.
|
|
79
88
|
*/
|
|
80
|
-
copyFrameData(frameData, frame) {
|
|
89
|
+
copyFrameData(frameData: import('./frame_data.js').FrameData, frame: string|number) {
|
|
81
90
|
this._frameData = frameData.clone();
|
|
82
91
|
if (this.isLoaded) {
|
|
83
92
|
// We need to update the frameData that the animations are using
|
|
@@ -107,7 +116,7 @@ export class AnimationManager {
|
|
|
107
116
|
* @param {boolean | undefined} useNumericIndex - Whether to treat frameList as numeric indices.
|
|
108
117
|
* @returns {Animation} The created Animation object.
|
|
109
118
|
*/
|
|
110
|
-
add(name, frameList, frameRate = 60, loop = false, useNumericIndex = undefined) {
|
|
119
|
+
add(name: string, frameList: number[] | string[] | null | undefined, frameRate: number = 60, loop: boolean = false, useNumericIndex: boolean | undefined = undefined) {
|
|
111
120
|
const frames = frameList || [];
|
|
112
121
|
// If they didn't set the useNumericIndex then let's at least try and guess it
|
|
113
122
|
if (useNumericIndex === undefined) {
|
|
@@ -141,7 +150,7 @@ export class AnimationManager {
|
|
|
141
150
|
* @param {boolean} useNumericIndex - Whether to treat frameList as numeric indices.
|
|
142
151
|
* @returns {boolean} True if all frames are valid, false otherwise.
|
|
143
152
|
*/
|
|
144
|
-
validateFrames(frames, useNumericIndex = false) {
|
|
153
|
+
validateFrames(frames: string[] | number[], useNumericIndex: boolean = false) {
|
|
145
154
|
for (let i = 0; i < frames.length; i += 1) {
|
|
146
155
|
if (useNumericIndex === true) {
|
|
147
156
|
if (frames[i] > this._frameData.total) {
|
|
@@ -161,7 +170,7 @@ export class AnimationManager {
|
|
|
161
170
|
* @param {boolean} loop - Whether the animation should loop, or null to use the animation's default.
|
|
162
171
|
* @returns {Animation} The Animation object that was played, or null if not found.
|
|
163
172
|
*/
|
|
164
|
-
play(name, frameRate = null, loop = null) {
|
|
173
|
+
play(name: string, frameRate: number = null, loop: boolean = null) {
|
|
165
174
|
if (this._anims[name]) {
|
|
166
175
|
if (this.currentAnim === this._anims[name]) {
|
|
167
176
|
if (this.currentAnim.isPlaying === false) {
|
|
@@ -186,7 +195,7 @@ export class AnimationManager {
|
|
|
186
195
|
* @param {string} name - The name of the animation to stop, or null to stop the current animation.
|
|
187
196
|
* @param {boolean} resetFrame - Whether to reset the frame to the first frame of the animation.
|
|
188
197
|
*/
|
|
189
|
-
stop(name = null, resetFrame = false) {
|
|
198
|
+
stop(name: string = null, resetFrame: boolean = false) {
|
|
190
199
|
if (this.currentAnim && (typeof name !== 'string' || name === this.currentAnim.name)) {
|
|
191
200
|
this.currentAnim.stop(resetFrame);
|
|
192
201
|
}
|
|
@@ -211,7 +220,7 @@ export class AnimationManager {
|
|
|
211
220
|
* Advances the current animation by a specified number of frames.
|
|
212
221
|
* @param {number} quantity - The number of frames to advance by.
|
|
213
222
|
*/
|
|
214
|
-
next(quantity) {
|
|
223
|
+
next(quantity: number) {
|
|
215
224
|
if (this.currentAnim) {
|
|
216
225
|
this.currentAnim.next(quantity);
|
|
217
226
|
this.currentFrame = this.currentAnim.currentFrame;
|
|
@@ -222,7 +231,7 @@ export class AnimationManager {
|
|
|
222
231
|
* Moves the current animation back by a specified number of frames.
|
|
223
232
|
* @param {number} quantity - The number of frames to move back by.
|
|
224
233
|
*/
|
|
225
|
-
previous(quantity) {
|
|
234
|
+
previous(quantity: number) {
|
|
226
235
|
if (this.currentAnim) {
|
|
227
236
|
this.currentAnim.previous(quantity);
|
|
228
237
|
this.currentFrame = this.currentAnim.currentFrame;
|
|
@@ -234,7 +243,7 @@ export class AnimationManager {
|
|
|
234
243
|
* @param {string} name - The name of the animation to retrieve.
|
|
235
244
|
* @returns {Animation} The Animation object, or null if not found.
|
|
236
245
|
*/
|
|
237
|
-
getAnimation(name) {
|
|
246
|
+
getAnimation(name: string) {
|
|
238
247
|
if (name && this._anims[name]) {
|
|
239
248
|
return this._anims[name];
|
|
240
249
|
}
|
|
@@ -346,4 +355,4 @@ export class AnimationManager {
|
|
|
346
355
|
});
|
|
347
356
|
}
|
|
348
357
|
}
|
|
349
|
-
}
|
|
358
|
+
}
|
|
@@ -12,8 +12,16 @@ import { FrameData } from './frame_data.js';
|
|
|
12
12
|
* @param {number} spacing - TBD.
|
|
13
13
|
* @returns {FrameData} TBD.
|
|
14
14
|
*/
|
|
15
|
-
export const spriteSheet = (
|
|
16
|
-
|
|
15
|
+
export const spriteSheet = (
|
|
16
|
+
game: import('./game.js').Game,
|
|
17
|
+
key: any,
|
|
18
|
+
frameWidth: number,
|
|
19
|
+
frameHeight: number,
|
|
20
|
+
frameMax: number,
|
|
21
|
+
margin: number,
|
|
22
|
+
spacing: number
|
|
23
|
+
) => {
|
|
24
|
+
let img: any = key;
|
|
17
25
|
if (typeof key === 'string') {
|
|
18
26
|
img = game.cache.getImage(key);
|
|
19
27
|
}
|
|
@@ -62,7 +70,7 @@ export const spriteSheet = (game, key, frameWidth, frameHeight, frameMax, margin
|
|
|
62
70
|
* @param {object} json - TBD.
|
|
63
71
|
* @returns {FrameData} TBD.
|
|
64
72
|
*/
|
|
65
|
-
export const JSONDataHash = (game, json) => {
|
|
73
|
+
export const JSONDataHash = (game: import('./game.js').Game, json: any, _key?: any) => {
|
|
66
74
|
if (!json.frames) {
|
|
67
75
|
game.logger.warn('JSONDataHash: Invalid Texture Atlas JSON given, missing frames object', json);
|
|
68
76
|
return null;
|
|
@@ -16,7 +16,7 @@ export class ArraySet {
|
|
|
16
16
|
* @param {object} item - TBD.
|
|
17
17
|
* @returns {object} TBD.
|
|
18
18
|
*/
|
|
19
|
-
add(item) {
|
|
19
|
+
add(item: any) {
|
|
20
20
|
if (!this.exists(item)) {
|
|
21
21
|
this.list.push(item);
|
|
22
22
|
}
|
|
@@ -28,7 +28,7 @@ export class ArraySet {
|
|
|
28
28
|
* @param {object} item - TBD.
|
|
29
29
|
* @returns {number} TBD.
|
|
30
30
|
*/
|
|
31
|
-
getIndex(item) {
|
|
31
|
+
getIndex(item: any) {
|
|
32
32
|
return this.list.indexOf(item);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ export class ArraySet {
|
|
|
38
38
|
* @param {object} value - TBD.
|
|
39
39
|
* @returns {object} TBD.
|
|
40
40
|
*/
|
|
41
|
-
getByKey(property, value) {
|
|
41
|
+
getByKey(property: string, value: any) {
|
|
42
42
|
let i = this.list.length;
|
|
43
43
|
while (i) {
|
|
44
44
|
i -= 1;
|
|
@@ -54,7 +54,7 @@ export class ArraySet {
|
|
|
54
54
|
* @param {object} item - TBD.
|
|
55
55
|
* @returns {boolean} TBD.
|
|
56
56
|
*/
|
|
57
|
-
exists(item) {
|
|
57
|
+
exists(item: any) {
|
|
58
58
|
return this.list.indexOf(item) > -1;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -70,7 +70,7 @@ export class ArraySet {
|
|
|
70
70
|
* @param {object} item - TBD.
|
|
71
71
|
* @returns {object} TBD.
|
|
72
72
|
*/
|
|
73
|
-
remove(item) {
|
|
73
|
+
remove(item: any) {
|
|
74
74
|
const idx = this.list.indexOf(item);
|
|
75
75
|
if (idx !== -1) {
|
|
76
76
|
this.list.splice(idx, 1);
|
|
@@ -84,7 +84,7 @@ export class ArraySet {
|
|
|
84
84
|
* @param {string} key - TBD.
|
|
85
85
|
* @param {object} value - TBD.
|
|
86
86
|
*/
|
|
87
|
-
setAll(key, value) {
|
|
87
|
+
setAll(key: string, value: any) {
|
|
88
88
|
let i = this.list.length;
|
|
89
89
|
while (i) {
|
|
90
90
|
i -= 1;
|
|
@@ -99,7 +99,7 @@ export class ArraySet {
|
|
|
99
99
|
* @param {string} key - TBD.
|
|
100
100
|
* @param {...any} args - TBD.
|
|
101
101
|
*/
|
|
102
|
-
callAll(key, ...args) {
|
|
102
|
+
callAll(key: string, ...args: any[]) {
|
|
103
103
|
let i = this.list.length;
|
|
104
104
|
while (i) {
|
|
105
105
|
i -= 1;
|
|
@@ -113,7 +113,7 @@ export class ArraySet {
|
|
|
113
113
|
* TBD.
|
|
114
114
|
* @param {boolean} destroy - TBD.
|
|
115
115
|
*/
|
|
116
|
-
removeAll(destroy = false) {
|
|
116
|
+
removeAll(destroy: boolean = false) {
|
|
117
117
|
let i = this.list.length;
|
|
118
118
|
while (i) {
|
|
119
119
|
i -= 1;
|