@vpmedia/phaser 1.95.0 → 1.97.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 +51 -0
- package/package.json +10 -10
- 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 +68 -52
- package/src/phaser/core/signal.test.js +37 -0
- 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 +79 -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/circle.test.js +1 -0
- package/src/phaser/geom/ellipse.js +28 -28
- package/src/phaser/geom/ellipse.test.js +1 -0
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/line.test.js +1 -0
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/matrix.test.js +1 -0
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/point.test.js +1 -0
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -132
- package/src/phaser/geom/rectangle.test.js +1 -0
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/rounded_rectangle.test.js +1 -0
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/circle.test.js +1 -0
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/ellipse.test.js +1 -0
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/line.test.js +1 -0
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/matrix.test.js +1 -0
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/point.test.js +1 -0
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/polygon.test.js +1 -0
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rectangle.test.js +1 -0
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/geom/util/rounded_rectangle.test.js +1 -0
- package/src/phaser/util/math.js +81 -81
- package/src/phaser/util/math.test.js +1 -0
- 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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
+
## [1.97.0] - 2025-12-29
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- Added signal async support
|
|
6
|
+
- Added async wait to timer
|
|
7
|
+
|
|
8
|
+
### 💼 Other
|
|
9
|
+
|
|
10
|
+
- *(deps)* Bump dependency versions
|
|
11
|
+
- *(deps)* Bump dependency versions
|
|
12
|
+
- *(deps)* Bump dependency versions
|
|
13
|
+
- *(deps)* Bump dependency versions
|
|
14
|
+
- *(deps)* Bump dependency versions
|
|
15
|
+
- *(deps)* Bump dependency versions
|
|
16
|
+
- *(deps)* Bump dependency versions
|
|
17
|
+
|
|
18
|
+
### ⚙️ Miscellaneous Tasks
|
|
19
|
+
|
|
20
|
+
- Release
|
|
21
|
+
- Improve type checking
|
|
22
|
+
- *(release)* V1.97.0
|
|
23
|
+
## [1.96.0] - 2025-12-17
|
|
24
|
+
|
|
25
|
+
### 💼 Other
|
|
26
|
+
|
|
27
|
+
- *(deps)* Bump dependency versions
|
|
28
|
+
|
|
29
|
+
### 📚 Documentation
|
|
30
|
+
|
|
31
|
+
- Improve jsdocs
|
|
32
|
+
- Improve jsdoc comments
|
|
33
|
+
- Improve jsdoc comments
|
|
34
|
+
- Improve jsdoc comments
|
|
35
|
+
- Improve jsdoc comments
|
|
36
|
+
- Improve jsdoc comments
|
|
37
|
+
- Improve jsdoc comments
|
|
38
|
+
- Improve jsdoc comments
|
|
39
|
+
- Regenerated types
|
|
40
|
+
- Improve jsdoc comments
|
|
41
|
+
- Improve jsdoc comments
|
|
42
|
+
- Improved jsdoc comments
|
|
43
|
+
- Improve jsdoc comments
|
|
44
|
+
- Improve jsdoc comments
|
|
45
|
+
- Improve jsdoc comments
|
|
46
|
+
- Improve jsdoc comments
|
|
47
|
+
|
|
48
|
+
### ⚙️ Miscellaneous Tasks
|
|
49
|
+
|
|
50
|
+
- Release
|
|
51
|
+
- *(release)* V1.96.0
|
|
1
52
|
## [1.95.0] - 2025-12-16
|
|
2
53
|
|
|
3
54
|
### 💼 Other
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.97.0",
|
|
4
4
|
"description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,27 +23,27 @@
|
|
|
23
23
|
"types": "./types/index.d.ts",
|
|
24
24
|
"type": "module",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vpmedia/simplify": "^1.
|
|
26
|
+
"@vpmedia/simplify": "^1.53.0",
|
|
27
27
|
"uuid": "^13.0.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@commitlint/cli": "^20.2.0",
|
|
31
31
|
"@commitlint/config-conventional": "^20.2.0",
|
|
32
32
|
"@eslint/js": "^9.39.2",
|
|
33
|
-
"@types/node": "^25.0.
|
|
34
|
-
"@vitest/coverage-v8": "^4.0.
|
|
33
|
+
"@types/node": "^25.0.3",
|
|
34
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
35
35
|
"eslint": "^9.39.2",
|
|
36
36
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
37
|
-
"eslint-plugin-oxlint": "^1.
|
|
37
|
+
"eslint-plugin-oxlint": "^1.35.0",
|
|
38
38
|
"eslint-plugin-unicorn": "^62.0.0",
|
|
39
39
|
"globals": "^16.5.0",
|
|
40
|
-
"jsdom": "^27.
|
|
41
|
-
"oxlint": "^1.
|
|
42
|
-
"oxlint-tsgolint": "^0.
|
|
40
|
+
"jsdom": "^27.4.0",
|
|
41
|
+
"oxlint": "^1.35.0",
|
|
42
|
+
"oxlint-tsgolint": "^0.10.0",
|
|
43
43
|
"prettier": "^3.7.4",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
|
-
"typescript-eslint": "^8.
|
|
46
|
-
"vitest": "^4.0.
|
|
45
|
+
"typescript-eslint": "^8.50.1",
|
|
46
|
+
"vitest": "^4.0.16"
|
|
47
47
|
},
|
|
48
48
|
"browserslist": [
|
|
49
49
|
"> 0.5%",
|
|
@@ -2,14 +2,14 @@ import { Signal } from './signal.js';
|
|
|
2
2
|
|
|
3
3
|
export class Animation {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {import('./game.js').Game} game -
|
|
7
|
-
* @param {import('../display/image.js').Image} parent -
|
|
8
|
-
* @param {string} name -
|
|
9
|
-
* @param {import('./frame_data.js').FrameData} frameData -
|
|
10
|
-
* @param {string[]|number[]} frames -
|
|
11
|
-
* @param {number} frameRate -
|
|
12
|
-
* @param {boolean} loop -
|
|
5
|
+
* Creates a new Animation instance.
|
|
6
|
+
* @param {import('./game.js').Game} game - The game instance this animation belongs to.
|
|
7
|
+
* @param {import('../display/image.js').Image} parent - The Image object that owns this animation.
|
|
8
|
+
* @param {string} name - The unique name of this animation.
|
|
9
|
+
* @param {import('./frame_data.js').FrameData} frameData - The FrameData object that contains the frames for this animation.
|
|
10
|
+
* @param {string[]|number[]} frames - An array of frame identifiers (names or indices) to use in this animation.
|
|
11
|
+
* @param {number} frameRate - The frame rate at which this animation should play (frames per second).
|
|
12
|
+
* @param {boolean} loop - Whether the animation should loop when it completes.
|
|
13
13
|
*/
|
|
14
14
|
constructor(game, parent, name, frameData, frames, frameRate, loop = false) {
|
|
15
15
|
/** @type {import('./game.js').Game} */
|
|
@@ -58,10 +58,10 @@ export class Animation {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
* @param {number} frameRate -
|
|
63
|
-
* @param {boolean} loop -
|
|
64
|
-
* @returns {Animation}
|
|
61
|
+
* Plays this animation.
|
|
62
|
+
* @param {number} frameRate - The new frame rate to use for this animation (if null, uses the original frame rate).
|
|
63
|
+
* @param {boolean} loop - Whether to loop this animation (if null, uses the original loop setting).
|
|
64
|
+
* @returns {Animation} This Animation instance for chaining.
|
|
65
65
|
*/
|
|
66
66
|
play(frameRate = null, loop = null) {
|
|
67
67
|
if (typeof frameRate === 'number') {
|
|
@@ -88,7 +88,7 @@ export class Animation {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* Restarts this animation from the beginning.
|
|
92
92
|
*/
|
|
93
93
|
restart() {
|
|
94
94
|
this.isPlaying = true;
|
|
@@ -106,8 +106,8 @@ export class Animation {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
*
|
|
110
|
-
* @returns {Animation}
|
|
109
|
+
* Reverses the direction of this animation.
|
|
110
|
+
* @returns {Animation} This Animation instance for chaining.
|
|
111
111
|
*/
|
|
112
112
|
reverse() {
|
|
113
113
|
this.reversed = !this.reversed;
|
|
@@ -115,8 +115,8 @@ export class Animation {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
119
|
-
* @returns {Animation}
|
|
118
|
+
* Reverses the animation direction once, then returns to normal direction.
|
|
119
|
+
* @returns {Animation} This Animation instance for chaining.
|
|
120
120
|
*/
|
|
121
121
|
reverseOnce() {
|
|
122
122
|
this.onComplete.addOnce(this.reverse, this);
|
|
@@ -124,9 +124,9 @@ export class Animation {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @param {string|number} frameId -
|
|
129
|
-
* @param {boolean} useLocalFrameIndex -
|
|
127
|
+
* Sets the current frame of this animation.
|
|
128
|
+
* @param {string|number} frameId - The identifier (name or index) of the frame to set.
|
|
129
|
+
* @param {boolean} useLocalFrameIndex - If true, treats frameId as an index into the local frames array.
|
|
130
130
|
*/
|
|
131
131
|
setFrame(frameId, useLocalFrameIndex = false) {
|
|
132
132
|
let frameIndex;
|
|
@@ -158,9 +158,9 @@ export class Animation {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @param {boolean} resetFrame -
|
|
163
|
-
* @param {boolean} dispatchComplete -
|
|
161
|
+
* Stops this animation.
|
|
162
|
+
* @param {boolean} resetFrame - If true, resets to the first frame.
|
|
163
|
+
* @param {boolean} dispatchComplete - If true, dispatches the onComplete signal.
|
|
164
164
|
*/
|
|
165
165
|
stop(resetFrame = false, dispatchComplete = false) {
|
|
166
166
|
this.isPlaying = false;
|
|
@@ -179,7 +179,7 @@ export class Animation {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
182
|
+
* Called when the game is paused.
|
|
183
183
|
*/
|
|
184
184
|
onPause() {
|
|
185
185
|
if (this.isPlaying) {
|
|
@@ -188,7 +188,7 @@ export class Animation {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
191
|
+
* Called when the game is resumed.
|
|
192
192
|
*/
|
|
193
193
|
onResume() {
|
|
194
194
|
if (this.isPlaying) {
|
|
@@ -197,8 +197,8 @@ export class Animation {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @returns {boolean}
|
|
200
|
+
* Updates this animation.
|
|
201
|
+
* @returns {boolean} True if the animation was updated, false otherwise.
|
|
202
202
|
*/
|
|
203
203
|
update() {
|
|
204
204
|
if (this.isPaused) {
|
|
@@ -256,10 +256,10 @@ export class Animation {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
|
-
*
|
|
260
|
-
* @param {boolean} signalUpdate -
|
|
261
|
-
* @param {boolean} fromPlay -
|
|
262
|
-
* @returns {boolean}
|
|
259
|
+
* Updates the current frame of this animation.
|
|
260
|
+
* @param {boolean} signalUpdate - Whether to signal the update event.
|
|
261
|
+
* @param {boolean} fromPlay - Whether this call is from play().
|
|
262
|
+
* @returns {boolean} True if the frame was updated, false otherwise.
|
|
263
263
|
*/
|
|
264
264
|
updateCurrentFrame(signalUpdate, fromPlay = false) {
|
|
265
265
|
if (!this._frameData || !this.currentFrame) {
|
|
@@ -281,8 +281,8 @@ export class Animation {
|
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
|
-
*
|
|
285
|
-
* @param {number} quantity -
|
|
284
|
+
* Advances the animation to the next frame(s).
|
|
285
|
+
* @param {number} quantity - The number of frames to advance by.
|
|
286
286
|
*/
|
|
287
287
|
next(quantity = 1) {
|
|
288
288
|
let frame = this._frameIndex + quantity;
|
|
@@ -300,8 +300,8 @@ export class Animation {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param {number} quantity -
|
|
303
|
+
* Moves the animation to the previous frame(s).
|
|
304
|
+
* @param {number} quantity - The number of frames to move back by.
|
|
305
305
|
*/
|
|
306
306
|
previous(quantity = 1) {
|
|
307
307
|
let frame = this._frameIndex - quantity;
|
|
@@ -319,8 +319,8 @@ export class Animation {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @param {import('./frame_data.js').FrameData} frameData -
|
|
322
|
+
* Updates the frame data used by this animation.
|
|
323
|
+
* @param {import('./frame_data.js').FrameData} frameData - The new FrameData object to use.
|
|
324
324
|
*/
|
|
325
325
|
updateFrameData(frameData) {
|
|
326
326
|
this._frameData = frameData;
|
|
@@ -330,7 +330,7 @@ export class Animation {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
|
-
*
|
|
333
|
+
* Destroys this animation and cleans up resources.
|
|
334
334
|
*/
|
|
335
335
|
destroy() {
|
|
336
336
|
if (!this._frameData) {
|
|
@@ -354,7 +354,7 @@ export class Animation {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* Completes this animation, setting it to the final frame.
|
|
358
358
|
*/
|
|
359
359
|
complete() {
|
|
360
360
|
this._frameIndex = this._frames.length - 1;
|
|
@@ -367,15 +367,16 @@ export class Animation {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
/**
|
|
370
|
-
*
|
|
371
|
-
* @returns {boolean}
|
|
370
|
+
* Gets whether this animation is currently paused.
|
|
371
|
+
* @returns {boolean} True if the animation is paused, false otherwise.
|
|
372
372
|
*/
|
|
373
373
|
get paused() {
|
|
374
374
|
return this.isPaused;
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
/**
|
|
378
|
-
*
|
|
378
|
+
* Sets whether this animation is currently paused.
|
|
379
|
+
* @param {boolean} value - True to pause the animation, false to resume it.
|
|
379
380
|
*/
|
|
380
381
|
set paused(value) {
|
|
381
382
|
this.isPaused = value;
|
|
@@ -387,31 +388,32 @@ export class Animation {
|
|
|
387
388
|
}
|
|
388
389
|
|
|
389
390
|
/**
|
|
390
|
-
*
|
|
391
|
-
* @returns {boolean}
|
|
391
|
+
* Gets whether this animation is currently reversed.
|
|
392
|
+
* @returns {boolean} True if the animation is reversed, false otherwise.
|
|
392
393
|
*/
|
|
393
394
|
get reversed() {
|
|
394
395
|
return this.isReversed;
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
/**
|
|
398
|
-
*
|
|
399
|
+
* Sets whether this animation is currently reversed.
|
|
400
|
+
* @param {boolean} value - True to reverse the animation, false to normal direction.
|
|
399
401
|
*/
|
|
400
402
|
set reversed(value) {
|
|
401
403
|
this.isReversed = value;
|
|
402
404
|
}
|
|
403
405
|
|
|
404
406
|
/**
|
|
405
|
-
*
|
|
406
|
-
* @returns {number}
|
|
407
|
+
* Gets the total number of frames in this animation.
|
|
408
|
+
* @returns {number} The total number of frames.
|
|
407
409
|
*/
|
|
408
410
|
get frameTotal() {
|
|
409
411
|
return this._frames.length;
|
|
410
412
|
}
|
|
411
413
|
|
|
412
414
|
/**
|
|
413
|
-
*
|
|
414
|
-
* @returns {number}
|
|
415
|
+
* Gets the current frame index.
|
|
416
|
+
* @returns {number} The current frame index.
|
|
415
417
|
*/
|
|
416
418
|
get frame() {
|
|
417
419
|
if (this.currentFrame !== null) {
|
|
@@ -421,7 +423,8 @@ export class Animation {
|
|
|
421
423
|
}
|
|
422
424
|
|
|
423
425
|
/**
|
|
424
|
-
*
|
|
426
|
+
* Sets the current frame index.
|
|
427
|
+
* @param {number} value - The new frame index to set.
|
|
425
428
|
*/
|
|
426
429
|
set frame(value) {
|
|
427
430
|
this.currentFrame = this._frameData.getFrame(this._frames[value]);
|
|
@@ -435,15 +438,16 @@ export class Animation {
|
|
|
435
438
|
}
|
|
436
439
|
|
|
437
440
|
/**
|
|
438
|
-
*
|
|
439
|
-
* @returns {number}
|
|
441
|
+
* Gets the current animation speed (frame rate).
|
|
442
|
+
* @returns {number} The frame rate in frames per second.
|
|
440
443
|
*/
|
|
441
444
|
get speed() {
|
|
442
445
|
return 1000 / this.delay;
|
|
443
446
|
}
|
|
444
447
|
|
|
445
448
|
/**
|
|
446
|
-
*
|
|
449
|
+
* Sets the animation speed (frame rate).
|
|
450
|
+
* @param {number} value - The new frame rate in frames per second.
|
|
447
451
|
*/
|
|
448
452
|
set speed(value) {
|
|
449
453
|
if (value > 0) {
|
|
@@ -452,15 +456,16 @@ export class Animation {
|
|
|
452
456
|
}
|
|
453
457
|
|
|
454
458
|
/**
|
|
455
|
-
*
|
|
456
|
-
* @returns {boolean}
|
|
459
|
+
* Gets whether the update signal is enabled.
|
|
460
|
+
* @returns {boolean} True if the update signal is enabled, false otherwise.
|
|
457
461
|
*/
|
|
458
462
|
get enableUpdate() {
|
|
459
463
|
return this.onUpdate !== null;
|
|
460
464
|
}
|
|
461
465
|
|
|
462
466
|
/**
|
|
463
|
-
*
|
|
467
|
+
* Sets whether the update signal is enabled.
|
|
468
|
+
* @param {boolean} value - True to enable the update signal, false to disable it.
|
|
464
469
|
*/
|
|
465
470
|
set enableUpdate(value) {
|
|
466
471
|
if (value && this.onUpdate === null) {
|
|
@@ -3,8 +3,8 @@ import { ENGINE_ERROR_CANNOT_SET_FRAME, ENGINE_ERROR_CANNOT_SET_FRAME_NAME } fro
|
|
|
3
3
|
|
|
4
4
|
export class AnimationManager {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {import('../display/image.js').Image} sprite -
|
|
6
|
+
* Creates a new AnimationManager instance.
|
|
7
|
+
* @param {import('../display/image.js').Image} sprite - Reference to the parent Sprite.
|
|
8
8
|
*/
|
|
9
9
|
constructor(sprite) {
|
|
10
10
|
this.sprite = sprite;
|
|
@@ -24,7 +24,7 @@ export class AnimationManager {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Destroys the AnimationManager and cleans up resources.
|
|
28
28
|
*/
|
|
29
29
|
destroy() {
|
|
30
30
|
const keys = Object.keys(this._anims);
|
|
@@ -41,10 +41,10 @@ export class AnimationManager {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {import('./frame_data.js').FrameData} frameData -
|
|
46
|
-
* @param {string|number} frame -
|
|
47
|
-
* @returns {boolean}
|
|
44
|
+
* Loads frame data into the AnimationManager.
|
|
45
|
+
* @param {import('./frame_data.js').FrameData} frameData - The FrameData to load.
|
|
46
|
+
* @param {string|number} frame - The frame index or name to set as current.
|
|
47
|
+
* @returns {boolean} True if the frame data was loaded successfully, false otherwise.
|
|
48
48
|
*/
|
|
49
49
|
loadFrameData(frameData, frame) {
|
|
50
50
|
if (!frameData) {
|
|
@@ -71,10 +71,10 @@ export class AnimationManager {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {import('./frame_data.js').FrameData} frameData -
|
|
76
|
-
* @param {string|number} frame -
|
|
77
|
-
* @returns {boolean}
|
|
74
|
+
* Copies frame data into the AnimationManager.
|
|
75
|
+
* @param {import('./frame_data.js').FrameData} frameData - The FrameData to copy.
|
|
76
|
+
* @param {string|number} frame - The frame index or name to set as current.
|
|
77
|
+
* @returns {boolean} True if the frame data was copied successfully, false otherwise.
|
|
78
78
|
*/
|
|
79
79
|
copyFrameData(frameData, frame) {
|
|
80
80
|
this._frameData = frameData.clone();
|
|
@@ -98,13 +98,13 @@ export class AnimationManager {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param {string} name -
|
|
103
|
-
* @param {number[] | string[] | null | undefined} frameList -
|
|
104
|
-
* @param {number} frameRate -
|
|
105
|
-
* @param {boolean} loop -
|
|
106
|
-
* @param {boolean | undefined} useNumericIndex -
|
|
107
|
-
* @returns {Animation}
|
|
101
|
+
* Adds a new animation to the AnimationManager.
|
|
102
|
+
* @param {string} name - The name of the animation.
|
|
103
|
+
* @param {number[] | string[] | null | undefined} frameList - The list of frames to include in the animation.
|
|
104
|
+
* @param {number} frameRate - The frame rate of the animation (frames per second).
|
|
105
|
+
* @param {boolean} loop - Whether the animation should loop.
|
|
106
|
+
* @param {boolean | undefined} useNumericIndex - Whether to treat frameList as numeric indices.
|
|
107
|
+
* @returns {Animation} The created Animation object.
|
|
108
108
|
*/
|
|
109
109
|
add(name, frameList, frameRate = 60, loop = false, useNumericIndex = undefined) {
|
|
110
110
|
const frames = frameList || [];
|
|
@@ -135,10 +135,10 @@ export class AnimationManager {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @param {string[] | number[]} frames -
|
|
140
|
-
* @param {boolean} useNumericIndex -
|
|
141
|
-
* @returns {boolean}
|
|
138
|
+
* Validates a list of frames against the current frame data.
|
|
139
|
+
* @param {string[] | number[]} frames - The list of frames to validate.
|
|
140
|
+
* @param {boolean} useNumericIndex - Whether to treat frameList as numeric indices.
|
|
141
|
+
* @returns {boolean} True if all frames are valid, false otherwise.
|
|
142
142
|
*/
|
|
143
143
|
validateFrames(frames, useNumericIndex = false) {
|
|
144
144
|
for (let i = 0; i < frames.length; i += 1) {
|
|
@@ -154,11 +154,11 @@ export class AnimationManager {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
* @param {string} name -
|
|
159
|
-
* @param {number} frameRate -
|
|
160
|
-
* @param {boolean} loop -
|
|
161
|
-
* @returns {Animation}
|
|
157
|
+
* Plays an animation by name.
|
|
158
|
+
* @param {string} name - The name of the animation to play.
|
|
159
|
+
* @param {number} frameRate - The frame rate (frames per second) to play at, or null to use the animation's default.
|
|
160
|
+
* @param {boolean} loop - Whether the animation should loop, or null to use the animation's default.
|
|
161
|
+
* @returns {Animation} The Animation object that was played, or null if not found.
|
|
162
162
|
*/
|
|
163
163
|
play(name, frameRate = null, loop = null) {
|
|
164
164
|
if (this._anims[name]) {
|
|
@@ -181,9 +181,9 @@ export class AnimationManager {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @param {string} name -
|
|
186
|
-
* @param {boolean} resetFrame -
|
|
184
|
+
* Stops an animation by name.
|
|
185
|
+
* @param {string} name - The name of the animation to stop, or null to stop the current animation.
|
|
186
|
+
* @param {boolean} resetFrame - Whether to reset the frame to the first frame of the animation.
|
|
187
187
|
*/
|
|
188
188
|
stop(name = null, resetFrame = false) {
|
|
189
189
|
if (this.currentAnim && (typeof name !== 'string' || name === this.currentAnim.name)) {
|
|
@@ -192,8 +192,8 @@ export class AnimationManager {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @returns {boolean}
|
|
195
|
+
* Updates the animation manager state.
|
|
196
|
+
* @returns {boolean} True if an animation was updated, false otherwise.
|
|
197
197
|
*/
|
|
198
198
|
update() {
|
|
199
199
|
if (this.updateIfVisible && !this.sprite.visible) {
|
|
@@ -207,8 +207,8 @@ export class AnimationManager {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
/**
|
|
210
|
-
*
|
|
211
|
-
* @param {number} quantity -
|
|
210
|
+
* Advances the current animation by a specified number of frames.
|
|
211
|
+
* @param {number} quantity - The number of frames to advance by.
|
|
212
212
|
*/
|
|
213
213
|
next(quantity) {
|
|
214
214
|
if (this.currentAnim) {
|
|
@@ -218,8 +218,8 @@ export class AnimationManager {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
|
-
*
|
|
222
|
-
* @param {number} quantity -
|
|
221
|
+
* Moves the current animation back by a specified number of frames.
|
|
222
|
+
* @param {number} quantity - The number of frames to move back by.
|
|
223
223
|
*/
|
|
224
224
|
previous(quantity) {
|
|
225
225
|
if (this.currentAnim) {
|
|
@@ -229,9 +229,9 @@ export class AnimationManager {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param {string} name -
|
|
234
|
-
* @returns {Animation}
|
|
232
|
+
* Gets an animation by name.
|
|
233
|
+
* @param {string} name - The name of the animation to retrieve.
|
|
234
|
+
* @returns {Animation} The Animation object, or null if not found.
|
|
235
235
|
*/
|
|
236
236
|
getAnimation(name) {
|
|
237
237
|
if (name && this._anims[name]) {
|
|
@@ -241,7 +241,7 @@ export class AnimationManager {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
|
-
*
|
|
244
|
+
* Refreshes the current frame texture (not implemented).
|
|
245
245
|
*/
|
|
246
246
|
refreshFrame() {
|
|
247
247
|
// TODO
|
|
@@ -250,39 +250,39 @@ export class AnimationManager {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
*
|
|
254
|
-
* @returns {import('./frame_data.js').FrameData}
|
|
253
|
+
* Gets the frame data used by this AnimationManager.
|
|
254
|
+
* @returns {import('./frame_data.js').FrameData} The FrameData object.
|
|
255
255
|
*/
|
|
256
256
|
get frameData() {
|
|
257
257
|
return this._frameData;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
|
-
*
|
|
262
|
-
* @returns {number}
|
|
261
|
+
* Gets the total number of frames in the frame data.
|
|
262
|
+
* @returns {number} The total number of frames.
|
|
263
263
|
*/
|
|
264
264
|
get frameTotal() {
|
|
265
265
|
return this._frameData.total;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
|
-
*
|
|
270
|
-
* @returns {boolean}
|
|
269
|
+
* Gets the paused state of the current animation.
|
|
270
|
+
* @returns {boolean} True if the current animation is paused, false otherwise.
|
|
271
271
|
*/
|
|
272
272
|
get paused() {
|
|
273
273
|
return this.currentAnim.isPaused;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* Sets the paused state of the current animation.
|
|
278
278
|
*/
|
|
279
279
|
set paused(value) {
|
|
280
280
|
this.currentAnim.paused = value;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
|
-
*
|
|
285
|
-
* @returns {string}
|
|
284
|
+
* Gets the name of the current animation.
|
|
285
|
+
* @returns {string} The name of the current animation, or null if no animation is active.
|
|
286
286
|
*/
|
|
287
287
|
get name() {
|
|
288
288
|
if (this.currentAnim) {
|
|
@@ -292,8 +292,8 @@ export class AnimationManager {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
/**
|
|
295
|
-
*
|
|
296
|
-
* @returns {number}
|
|
295
|
+
* Gets the current frame index.
|
|
296
|
+
* @returns {number} The current frame index.
|
|
297
297
|
*/
|
|
298
298
|
get frame() {
|
|
299
299
|
if (this.currentFrame) {
|
|
@@ -303,7 +303,7 @@ export class AnimationManager {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
|
-
*
|
|
306
|
+
* Sets the current frame index.
|
|
307
307
|
*/
|
|
308
308
|
set frame(value) {
|
|
309
309
|
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null) {
|
|
@@ -319,8 +319,8 @@ export class AnimationManager {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @returns {string}
|
|
322
|
+
* Gets the current frame name.
|
|
323
|
+
* @returns {string} The current frame name, or null if no frame is set.
|
|
324
324
|
*/
|
|
325
325
|
get frameName() {
|
|
326
326
|
if (this.currentFrame) {
|
|
@@ -330,7 +330,7 @@ export class AnimationManager {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
|
-
*
|
|
333
|
+
* Sets the current frame by name.
|
|
334
334
|
*/
|
|
335
335
|
set frameName(value) {
|
|
336
336
|
if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null) {
|