@vpmedia/phaser 1.94.0 → 1.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/package.json +11 -11
- package/src/phaser/core/animation.js +79 -56
- package/src/phaser/core/animation_manager.js +55 -55
- package/src/phaser/core/animation_parser.js +2 -2
- package/src/phaser/core/cache.js +154 -154
- package/src/phaser/core/device.js +2 -1
- package/src/phaser/core/device_util.js +27 -27
- package/src/phaser/core/dom.js +43 -43
- package/src/phaser/core/event_manager.js +63 -63
- package/src/phaser/core/factory.js +47 -47
- package/src/phaser/core/frame.js +30 -30
- package/src/phaser/core/frame_data.js +30 -28
- package/src/phaser/core/frame_util.js +8 -8
- package/src/phaser/core/game.js +35 -19
- package/src/phaser/core/input_pointer.js +18 -0
- package/src/phaser/core/loader.js +171 -171
- package/src/phaser/core/loader_parser.js +22 -22
- package/src/phaser/core/raf.js +1 -1
- package/src/phaser/core/scale_manager.js +3 -2
- package/src/phaser/core/scene.js +16 -10
- package/src/phaser/core/scene_manager.js +51 -43
- package/src/phaser/core/signal.js +56 -52
- package/src/phaser/core/sound.js +54 -54
- package/src/phaser/core/sound_manager.js +49 -49
- package/src/phaser/core/stage.js +16 -16
- package/src/phaser/core/time.js +54 -30
- package/src/phaser/core/timer.js +82 -64
- package/src/phaser/core/timer_event.js +9 -9
- package/src/phaser/core/tween.js +106 -90
- package/src/phaser/core/tween_data.js +30 -30
- package/src/phaser/core/tween_manager.js +32 -24
- package/src/phaser/core/world.js +4 -3
- package/src/phaser/display/bitmap_text.js +72 -54
- package/src/phaser/display/button.js +48 -47
- package/src/phaser/display/canvas/buffer.js +8 -8
- package/src/phaser/display/canvas/graphics.js +8 -8
- package/src/phaser/display/canvas/masker.js +5 -5
- package/src/phaser/display/canvas/pool.js +18 -18
- package/src/phaser/display/canvas/renderer.js +17 -16
- package/src/phaser/display/canvas/tinter.js +22 -22
- package/src/phaser/display/canvas/util.js +42 -42
- package/src/phaser/display/display_object.js +119 -108
- package/src/phaser/display/graphics.js +129 -112
- package/src/phaser/display/graphics_data.js +10 -10
- package/src/phaser/display/graphics_data_util.js +3 -3
- package/src/phaser/display/group.js +63 -50
- package/src/phaser/display/image.js +68 -50
- package/src/phaser/display/sprite_batch.js +2 -2
- package/src/phaser/display/sprite_util.js +19 -19
- package/src/phaser/display/text.js +217 -187
- package/src/phaser/display/webgl/abstract_filter.js +4 -4
- package/src/phaser/display/webgl/base_texture.js +9 -9
- package/src/phaser/display/webgl/blend_manager.js +7 -7
- package/src/phaser/display/webgl/earcut.js +95 -95
- package/src/phaser/display/webgl/earcut_node.js +4 -4
- package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
- package/src/phaser/display/webgl/filter_manager.js +9 -9
- package/src/phaser/display/webgl/filter_texture.js +10 -10
- package/src/phaser/display/webgl/graphics.js +37 -37
- package/src/phaser/display/webgl/graphics_data.js +4 -4
- package/src/phaser/display/webgl/mask_manager.js +6 -6
- package/src/phaser/display/webgl/render_texture.js +16 -16
- package/src/phaser/display/webgl/renderer.js +21 -20
- package/src/phaser/display/webgl/shader/complex.js +4 -4
- package/src/phaser/display/webgl/shader/fast.js +4 -4
- package/src/phaser/display/webgl/shader/normal.js +8 -8
- package/src/phaser/display/webgl/shader/primitive.js +4 -4
- package/src/phaser/display/webgl/shader/strip.js +4 -4
- package/src/phaser/display/webgl/shader_manager.js +9 -9
- package/src/phaser/display/webgl/sprite_batch.js +18 -18
- package/src/phaser/display/webgl/stencil_manager.js +16 -16
- package/src/phaser/display/webgl/texture.js +13 -13
- package/src/phaser/display/webgl/texture_util.js +8 -8
- package/src/phaser/display/webgl/util.js +25 -25
- package/src/phaser/geom/circle.js +74 -69
- package/src/phaser/geom/ellipse.js +33 -28
- package/src/phaser/geom/line.js +96 -93
- package/src/phaser/geom/matrix.js +61 -54
- package/src/phaser/geom/point.js +99 -96
- package/src/phaser/geom/polygon.js +27 -22
- package/src/phaser/geom/rectangle.js +137 -132
- package/src/phaser/geom/rounded_rectangle.js +12 -12
- package/src/phaser/geom/util/circle.js +33 -33
- package/src/phaser/geom/util/ellipse.js +5 -5
- package/src/phaser/geom/util/line.js +26 -26
- package/src/phaser/geom/util/matrix.js +8 -8
- package/src/phaser/geom/util/point.js +97 -97
- package/src/phaser/geom/util/polygon.js +4 -4
- package/src/phaser/geom/util/rectangle.js +74 -74
- package/src/phaser/geom/util/rounded_rectangle.js +4 -4
- package/src/phaser/util/math.js +81 -81
- package/types/phaser/core/animation.d.ts +79 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/animation_parser.d.ts +3 -2
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +51 -44
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -21
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +18 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +175 -172
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scale_manager.d.ts +6 -5
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +54 -30
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +82 -64
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +106 -90
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +35 -67
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +76 -53
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/graphics.d.ts +3 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +6 -3
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +18 -17
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +6 -6
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +118 -102
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +59 -47
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +58 -45
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +237 -188
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +10 -10
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics.d.ts +2 -2
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +21 -20
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/display/webgl/texture_util.d.ts +4 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +74 -69
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +33 -28
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +96 -93
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +61 -54
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +99 -96
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +29 -23
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +137 -132
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/types/phaser/geom/util/point.d.ts +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/pnpm-workspace.yaml +0 -4
|
@@ -7,21 +7,21 @@ import { Text } from '../display/text.js';
|
|
|
7
7
|
|
|
8
8
|
export class GameObjectFactory {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {import('./game.js').Game} game -
|
|
10
|
+
* Creates a new GameObjectFactory instance.
|
|
11
|
+
* @param {import('./game.js').Game} game - The game instance this factory belongs to.
|
|
12
12
|
*/
|
|
13
13
|
constructor(game) {
|
|
14
14
|
this.game = game;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {number} x -
|
|
20
|
-
* @param {number} y -
|
|
21
|
-
* @param {string} key -
|
|
22
|
-
* @param {string|number} frame -
|
|
23
|
-
* @param {Group} group -
|
|
24
|
-
* @returns {Image}
|
|
18
|
+
* Creates a new Image object.
|
|
19
|
+
* @param {number} x - The x coordinate of the image.
|
|
20
|
+
* @param {number} y - The y coordinate of the image.
|
|
21
|
+
* @param {string} key - The texture key for the image.
|
|
22
|
+
* @param {string|number} frame - The frame to display.
|
|
23
|
+
* @param {Group} group - The parent group for the image.
|
|
24
|
+
* @returns {Image} The created Image object.
|
|
25
25
|
*/
|
|
26
26
|
image(x, y, key, frame, group = null) {
|
|
27
27
|
if (!group) {
|
|
@@ -31,24 +31,24 @@ export class GameObjectFactory {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {Group | null} parent -
|
|
36
|
-
* @param {string | null} name -
|
|
37
|
-
* @param {boolean} addToStage -
|
|
38
|
-
* @returns {Group}
|
|
34
|
+
* Creates a new Group object.
|
|
35
|
+
* @param {Group | null} parent - The parent group for the new group.
|
|
36
|
+
* @param {string | null} name - The name of the group.
|
|
37
|
+
* @param {boolean} addToStage - Whether to add the group to the stage.
|
|
38
|
+
* @returns {Group} The created Group object.
|
|
39
39
|
*/
|
|
40
40
|
group(parent = null, name = null, addToStage = false) {
|
|
41
41
|
return new Group(this.game, parent, name, addToStage);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {number} x -
|
|
47
|
-
* @param {number} y -
|
|
48
|
-
* @param {string} text -
|
|
49
|
-
* @param {object} style -
|
|
50
|
-
* @param {Group | null} group -
|
|
51
|
-
* @returns {Text}
|
|
45
|
+
* Creates a new Text object.
|
|
46
|
+
* @param {number} x - The x coordinate of the text.
|
|
47
|
+
* @param {number} y - The y coordinate of the text.
|
|
48
|
+
* @param {string} text - The text content to display.
|
|
49
|
+
* @param {object} style - The style configuration for the text.
|
|
50
|
+
* @param {Group | null} group - The parent group for the text.
|
|
51
|
+
* @returns {Text} The created Text object.
|
|
52
52
|
*/
|
|
53
53
|
text(x, y, text, style, group = null) {
|
|
54
54
|
const parent = group || this.game.world;
|
|
@@ -56,18 +56,18 @@ export class GameObjectFactory {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param {number} x -
|
|
61
|
-
* @param {number} y -
|
|
62
|
-
* @param {string} key -
|
|
63
|
-
* @param {Function | null} callback -
|
|
64
|
-
* @param {object | null} callbackContext -
|
|
65
|
-
* @param {string | null} overFrame -
|
|
66
|
-
* @param {string | null} outFrame -
|
|
67
|
-
* @param {string | null} downFrame -
|
|
68
|
-
* @param {string | null} upFrame -
|
|
69
|
-
* @param {Group | null} group -
|
|
70
|
-
* @returns {Button}
|
|
59
|
+
* Creates a new Button object.
|
|
60
|
+
* @param {number} x - The x coordinate of the button.
|
|
61
|
+
* @param {number} y - The y coordinate of the button.
|
|
62
|
+
* @param {string} key - The texture key for the button.
|
|
63
|
+
* @param {Function | null} callback - The function to call when the button is clicked.
|
|
64
|
+
* @param {object | null} callbackContext - The context to apply when calling the callback.
|
|
65
|
+
* @param {string | null} overFrame - The frame to display when the mouse is over the button.
|
|
66
|
+
* @param {string | null} outFrame - The frame to display when the mouse is not over the button.
|
|
67
|
+
* @param {string | null} downFrame - The frame to display when the button is pressed.
|
|
68
|
+
* @param {string | null} upFrame - The frame to display when the button is released.
|
|
69
|
+
* @param {Group | null} group - The parent group for the button.
|
|
70
|
+
* @returns {Button} The created Button object.
|
|
71
71
|
*/
|
|
72
72
|
button(
|
|
73
73
|
x,
|
|
@@ -88,11 +88,11 @@ export class GameObjectFactory {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @param {number} x -
|
|
93
|
-
* @param {number} y -
|
|
94
|
-
* @param {Group | null} group -
|
|
95
|
-
* @returns {Graphics}
|
|
91
|
+
* Creates a new Graphics object.
|
|
92
|
+
* @param {number} x - The x coordinate of the graphics object.
|
|
93
|
+
* @param {number} y - The y coordinate of the graphics object.
|
|
94
|
+
* @param {Group | null} group - The parent group for the graphics object.
|
|
95
|
+
* @returns {Graphics} The created Graphics object.
|
|
96
96
|
*/
|
|
97
97
|
graphics(x = 0, y = 0, group = null) {
|
|
98
98
|
const parent = group || this.game.world;
|
|
@@ -100,15 +100,15 @@ export class GameObjectFactory {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
104
|
-
* @param {number} x -
|
|
105
|
-
* @param {number} y -
|
|
106
|
-
* @param {string} font -
|
|
107
|
-
* @param {string} text -
|
|
108
|
-
* @param {number} size -
|
|
109
|
-
* @param {Group | null} group -
|
|
110
|
-
* @param {string} align -
|
|
111
|
-
* @returns {BitmapText}
|
|
103
|
+
* Creates a new BitmapText object.
|
|
104
|
+
* @param {number} x - The x coordinate of the bitmap text.
|
|
105
|
+
* @param {number} y - The y coordinate of the bitmap text.
|
|
106
|
+
* @param {string} font - The font key for the bitmap text.
|
|
107
|
+
* @param {string} text - The text content to display.
|
|
108
|
+
* @param {number} size - The font size.
|
|
109
|
+
* @param {Group | null} group - The parent group for the bitmap text.
|
|
110
|
+
* @param {string} align - The alignment of the text.
|
|
111
|
+
* @returns {BitmapText} The created BitmapText object.
|
|
112
112
|
*/
|
|
113
113
|
bitmapText(x, y, font, text, size, group = null, align = 'left') {
|
|
114
114
|
const parent = group || this.game.world;
|
package/src/phaser/core/frame.js
CHANGED
|
@@ -4,26 +4,26 @@ import { cloneFrame } from './frame_util.js';
|
|
|
4
4
|
|
|
5
5
|
export class Frame {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {number} index -
|
|
9
|
-
* @param {number} x -
|
|
10
|
-
* @param {number} y -
|
|
11
|
-
* @param {number} width -
|
|
12
|
-
* @param {number} height -
|
|
13
|
-
* @param {string} name -
|
|
7
|
+
* Creates a new Frame instance.
|
|
8
|
+
* @param {number} index - The index of this frame in the animation.
|
|
9
|
+
* @param {number} x - The x coordinate of this frame's position in the texture.
|
|
10
|
+
* @param {number} y - The y coordinate of this frame's position in the texture.
|
|
11
|
+
* @param {number} width - The width of this frame in pixels.
|
|
12
|
+
* @param {number} height - The height of this frame in pixels.
|
|
13
|
+
* @param {string} name - The name of this frame.
|
|
14
14
|
*/
|
|
15
15
|
constructor(index, x, y, width, height, name) {
|
|
16
16
|
this.initialize(index, x, y, width, height, name);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {number} index -
|
|
22
|
-
* @param {number} x -
|
|
23
|
-
* @param {number} y -
|
|
24
|
-
* @param {number} width -
|
|
25
|
-
* @param {number} height -
|
|
26
|
-
* @param {string} name -
|
|
20
|
+
* Initializes this frame with the specified properties.
|
|
21
|
+
* @param {number} index - The index of this frame in the animation.
|
|
22
|
+
* @param {number} x - The x coordinate of this frame's position in the texture.
|
|
23
|
+
* @param {number} y - The y coordinate of this frame's position in the texture.
|
|
24
|
+
* @param {number} width - The width of this frame in pixels.
|
|
25
|
+
* @param {number} height - The height of this frame in pixels.
|
|
26
|
+
* @param {string} name - The name of this frame.
|
|
27
27
|
*/
|
|
28
28
|
initialize(index, x, y, width, height, name) {
|
|
29
29
|
this.index = index;
|
|
@@ -49,9 +49,9 @@ export class Frame {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param {number} width -
|
|
54
|
-
* @param {number} height -
|
|
52
|
+
* Resizes this frame to the specified dimensions.
|
|
53
|
+
* @param {number} width - The new width of this frame in pixels.
|
|
54
|
+
* @param {number} height - The new height of this frame in pixels.
|
|
55
55
|
*/
|
|
56
56
|
resize(width, height) {
|
|
57
57
|
this.width = width;
|
|
@@ -66,14 +66,14 @@ export class Frame {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param {boolean} trimmed -
|
|
71
|
-
* @param {number} actualWidth -
|
|
72
|
-
* @param {number} actualHeight -
|
|
73
|
-
* @param {number} destX -
|
|
74
|
-
* @param {number} destY -
|
|
75
|
-
* @param {number} destWidth -
|
|
76
|
-
* @param {number} destHeight -
|
|
69
|
+
* Sets the trim properties for this frame.
|
|
70
|
+
* @param {boolean} trimmed - Whether this frame is trimmed.
|
|
71
|
+
* @param {number} actualWidth - The actual width of the trimmed frame.
|
|
72
|
+
* @param {number} actualHeight - The actual height of the trimmed frame.
|
|
73
|
+
* @param {number} destX - The destination x coordinate for the trimmed frame.
|
|
74
|
+
* @param {number} destY - The destination y coordinate for the trimmed frame.
|
|
75
|
+
* @param {number} destWidth - The destination width of the trimmed frame.
|
|
76
|
+
* @param {number} destHeight - The destination height of the trimmed frame.
|
|
77
77
|
*/
|
|
78
78
|
setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
|
79
79
|
this.trimmed = trimmed;
|
|
@@ -90,17 +90,17 @@ export class Frame {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
94
|
-
* @returns {Frame}
|
|
93
|
+
* Creates a clone of this frame.
|
|
94
|
+
* @returns {Frame} A new Frame instance with the same properties.
|
|
95
95
|
*/
|
|
96
96
|
clone() {
|
|
97
97
|
return cloneFrame(this);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
*
|
|
102
|
-
* @param {Rectangle} output -
|
|
103
|
-
* @returns {Rectangle}
|
|
101
|
+
* Gets the rectangle bounds of this frame.
|
|
102
|
+
* @param {Rectangle} output - The rectangle to use for the result (optional).
|
|
103
|
+
* @returns {Rectangle} A Rectangle object representing this frame's bounds.
|
|
104
104
|
*/
|
|
105
105
|
getRect(output = null) {
|
|
106
106
|
const result = output || new Rectangle();
|
|
@@ -2,7 +2,8 @@ import { cloneFrameData } from './frame_util.js';
|
|
|
2
2
|
|
|
3
3
|
export class FrameData {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Creates a new FrameData instance.
|
|
6
|
+
* This class holds data about frames in a texture atlas or sprite sheet.
|
|
6
7
|
*/
|
|
7
8
|
constructor() {
|
|
8
9
|
/**
|
|
@@ -16,9 +17,9 @@ export class FrameData {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param {import('./frame.js').Frame} frame -
|
|
21
|
-
* @returns {import('./frame.js').Frame}
|
|
20
|
+
* Add a frame to the frame data collection.
|
|
21
|
+
* @param {import('./frame.js').Frame} frame - The frame to add.
|
|
22
|
+
* @returns {import('./frame.js').Frame} The added frame.
|
|
22
23
|
*/
|
|
23
24
|
addFrame(frame) {
|
|
24
25
|
frame.index = this._frames.length;
|
|
@@ -30,9 +31,9 @@ export class FrameData {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @param {number} index -
|
|
35
|
-
* @returns {import('./frame.js').Frame}
|
|
34
|
+
* Get a frame by its index.
|
|
35
|
+
* @param {number} index - The index of the frame to get.
|
|
36
|
+
* @returns {import('./frame.js').Frame} The frame at the specified index, or the first frame if index is out of bounds.
|
|
36
37
|
*/
|
|
37
38
|
getFrame(index = 0) {
|
|
38
39
|
if (index >= this._frames.length) {
|
|
@@ -42,9 +43,9 @@ export class FrameData {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {string} name -
|
|
47
|
-
* @returns {import('./frame.js').Frame}
|
|
46
|
+
* Get a frame by its name.
|
|
47
|
+
* @param {string} name - The name of the frame to get.
|
|
48
|
+
* @returns {import('./frame.js').Frame} The frame with the specified name, or null if not found.
|
|
48
49
|
*/
|
|
49
50
|
getFrameByName(name) {
|
|
50
51
|
if (typeof this._frameNames[name] === 'number') {
|
|
@@ -54,9 +55,9 @@ export class FrameData {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {string} name -
|
|
59
|
-
* @returns {boolean}
|
|
58
|
+
* Check if a frame with the given name exists.
|
|
59
|
+
* @param {string} name - The name of the frame to check.
|
|
60
|
+
* @returns {boolean} True if a frame with this name exists, false otherwise.
|
|
60
61
|
*/
|
|
61
62
|
checkFrameName(name) {
|
|
62
63
|
if (this._frameNames[name] == null) {
|
|
@@ -66,19 +67,19 @@ export class FrameData {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @returns {FrameData}
|
|
70
|
+
* Create a clone of this FrameData instance.
|
|
71
|
+
* @returns {FrameData} A new FrameData instance with cloned frames.
|
|
71
72
|
*/
|
|
72
73
|
clone() {
|
|
73
74
|
return cloneFrameData(this);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
/**
|
|
77
|
-
*
|
|
78
|
-
* @param {number} start -
|
|
79
|
-
* @param {number} end -
|
|
80
|
-
* @param {import('./frame.js').Frame[]} output -
|
|
81
|
-
* @returns {import('./frame.js').Frame[]}
|
|
78
|
+
* Get a range of frames by index.
|
|
79
|
+
* @param {number} start - The starting index of the frame range.
|
|
80
|
+
* @param {number} end - The ending index of the frame range.
|
|
81
|
+
* @param {import('./frame.js').Frame[]} output - Optional array to populate with frames.
|
|
82
|
+
* @returns {import('./frame.js').Frame[]} An array of frames in the specified range.
|
|
82
83
|
*/
|
|
83
84
|
getFrameRange(start, end, output = null) {
|
|
84
85
|
const result = output || [];
|
|
@@ -89,11 +90,11 @@ export class FrameData {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param {number[]|string[]} frames -
|
|
94
|
-
* @param {boolean} useNumericIndex -
|
|
95
|
-
* @param {number[]} output -
|
|
96
|
-
* @returns {number[]}
|
|
93
|
+
* Get frame indexes from an array of frame names or indices.
|
|
94
|
+
* @param {number[]|string[]} frames - An array of frame names or indices.
|
|
95
|
+
* @param {boolean} useNumericIndex - Whether to treat numeric values as frame indices.
|
|
96
|
+
* @param {number[]} output - Optional array to populate with frame indexes.
|
|
97
|
+
* @returns {number[]} An array of frame indexes.
|
|
97
98
|
*/
|
|
98
99
|
getFrameIndexes(frames, useNumericIndex = true, output = null) {
|
|
99
100
|
const result = output || [];
|
|
@@ -114,7 +115,8 @@ export class FrameData {
|
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
/**
|
|
117
|
-
*
|
|
118
|
+
* Destroy this FrameData instance and clean up resources.
|
|
119
|
+
* This method clears internal arrays and releases references to frames.
|
|
118
120
|
*/
|
|
119
121
|
destroy() {
|
|
120
122
|
this._frames = null;
|
|
@@ -122,8 +124,8 @@ export class FrameData {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @returns {number}
|
|
127
|
+
* Get the total number of frames in this FrameData instance.
|
|
128
|
+
* @returns {number} The total number of frames.
|
|
127
129
|
*/
|
|
128
130
|
get total() {
|
|
129
131
|
return this._frames.length;
|
|
@@ -2,10 +2,10 @@ import { Frame } from './frame.js';
|
|
|
2
2
|
import { FrameData } from './frame_data.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {Frame} frame -
|
|
7
|
-
* @param {Frame} output -
|
|
8
|
-
* @returns {Frame}
|
|
5
|
+
* Clone a Frame object.
|
|
6
|
+
* @param {Frame} frame - The frame to clone.
|
|
7
|
+
* @param {Frame} output - Optional output frame to populate.
|
|
8
|
+
* @returns {Frame} The cloned frame or the provided output frame.
|
|
9
9
|
*/
|
|
10
10
|
export const cloneFrame = (frame, output = null) => {
|
|
11
11
|
const result = output || new Frame(frame.index, frame.x, frame.y, frame.width, frame.height);
|
|
@@ -14,10 +14,10 @@ export const cloneFrame = (frame, output = null) => {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @param {FrameData} frameData -
|
|
19
|
-
* @param {FrameData} output -
|
|
20
|
-
* @returns {FrameData}
|
|
17
|
+
* Clone a FrameData object.
|
|
18
|
+
* @param {FrameData} frameData - The frame data to clone.
|
|
19
|
+
* @param {FrameData} output - Optional output frame data to populate.
|
|
20
|
+
* @returns {FrameData} The cloned frame data or the provided output frame data.
|
|
21
21
|
*/
|
|
22
22
|
export const cloneFrameData = (frameData, output = null) => {
|
|
23
23
|
const result = output || new FrameData();
|
package/src/phaser/core/game.js
CHANGED
|
@@ -21,8 +21,24 @@ import { World } from './world.js';
|
|
|
21
21
|
|
|
22
22
|
export class Game {
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {object} gameConfig -
|
|
24
|
+
* Creates a new Game instance.
|
|
25
|
+
* @param {object} gameConfig - The configuration object for the game.
|
|
26
|
+
* @param {number} gameConfig.width - The width of the game canvas (default: 800).
|
|
27
|
+
* @param {number} gameConfig.height - The height of the game canvas (default: 600).
|
|
28
|
+
* @param {string} gameConfig.backgroundColor - The background color of the canvas (default: 0x000000).
|
|
29
|
+
* @param {string} gameConfig.canvasID - The ID of the canvas element (default: '').
|
|
30
|
+
* @param {object} gameConfig.canvasStyle - CSS styles to apply to the canvas.
|
|
31
|
+
* @param {number} gameConfig.resolution - The resolution scale factor (default: 1).
|
|
32
|
+
* @param {boolean} gameConfig.transparent - Whether the canvas should be transparent (default: false).
|
|
33
|
+
* @param {boolean} gameConfig.antialias - Whether to enable antialiasing (default: false).
|
|
34
|
+
* @param {boolean} gameConfig.preserveDrawingBuffer - Whether to preserve the drawing buffer (default: false).
|
|
35
|
+
* @param {boolean} gameConfig.clearBeforeRender - Whether to clear the canvas before rendering (default: true).
|
|
36
|
+
* @param {boolean} gameConfig.roundPixels - Whether to round pixel values (default: true).
|
|
37
|
+
* @param {number} gameConfig.renderType - The rendering type to use (default: RENDER_AUTO).
|
|
38
|
+
* @param {boolean} gameConfig.isForceDisabledAudio - Whether to force disable audio (default: false).
|
|
39
|
+
* @param {number} gameConfig.maxParallelDownloads - Maximum parallel downloads (default: 16).
|
|
40
|
+
* @param {string|HTMLElement} gameConfig.parent - The parent element to append the canvas to.
|
|
41
|
+
* @param {object} gameConfig.state - The initial state object or class.
|
|
26
42
|
*/
|
|
27
43
|
constructor(gameConfig = {}) {
|
|
28
44
|
if (!window.PhaserRegistry) {
|
|
@@ -53,7 +69,7 @@ export class Game {
|
|
|
53
69
|
this.logger = null;
|
|
54
70
|
/** @type {HTMLCanvasElement} */
|
|
55
71
|
this.canvas = null;
|
|
56
|
-
/** @type {
|
|
72
|
+
/** @type {CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext} */
|
|
57
73
|
this.context = null;
|
|
58
74
|
this.onPause = new Signal();
|
|
59
75
|
this.onResume = new Signal();
|
|
@@ -77,7 +93,7 @@ export class Game {
|
|
|
77
93
|
}
|
|
78
94
|
|
|
79
95
|
/**
|
|
80
|
-
*
|
|
96
|
+
* Boots the game and initializes all systems.
|
|
81
97
|
*/
|
|
82
98
|
boot() {
|
|
83
99
|
if (this.isBooted) {
|
|
@@ -113,7 +129,7 @@ export class Game {
|
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
/**
|
|
116
|
-
*
|
|
132
|
+
* Creates the renderer canvas element.
|
|
117
133
|
*/
|
|
118
134
|
createRendererCanvas() {
|
|
119
135
|
this.logger.info('createRendererCanvas');
|
|
@@ -136,7 +152,7 @@ export class Game {
|
|
|
136
152
|
}
|
|
137
153
|
|
|
138
154
|
/**
|
|
139
|
-
*
|
|
155
|
+
* Initializes the renderer and sets up the rendering context.
|
|
140
156
|
*/
|
|
141
157
|
initRenderer() {
|
|
142
158
|
let isWebGlReady = false;
|
|
@@ -184,10 +200,10 @@ export class Game {
|
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @param {object} config -
|
|
189
|
-
* @param {string} key -
|
|
190
|
-
* @param {*} defaultValue -
|
|
203
|
+
* Parses a configuration element and sets it on the game config.
|
|
204
|
+
* @param {object} config - The configuration object to parse from.
|
|
205
|
+
* @param {string} key - The configuration key to parse.
|
|
206
|
+
* @param {*} defaultValue - The default value if the key is not found in config.
|
|
191
207
|
*/
|
|
192
208
|
parseConfigElement(config, key, defaultValue) {
|
|
193
209
|
if (config[key] !== undefined) {
|
|
@@ -198,8 +214,8 @@ export class Game {
|
|
|
198
214
|
}
|
|
199
215
|
|
|
200
216
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param {object} config -
|
|
217
|
+
* Parses the configuration object and sets up game properties.
|
|
218
|
+
* @param {object} config - The configuration object to parse.
|
|
203
219
|
*/
|
|
204
220
|
parseConfig(config) {
|
|
205
221
|
this.logger = config.logger ?? new Logger('phaser');
|
|
@@ -229,8 +245,8 @@ export class Game {
|
|
|
229
245
|
}
|
|
230
246
|
|
|
231
247
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param {WebGLContextEvent | Event} event -
|
|
248
|
+
* Called when the WebGL context is lost.
|
|
249
|
+
* @param {WebGLContextEvent | Event} event - The WebGL context loss event.
|
|
234
250
|
*/
|
|
235
251
|
contextLost(event) {
|
|
236
252
|
this.logger.info('contextLost', event);
|
|
@@ -241,8 +257,8 @@ export class Game {
|
|
|
241
257
|
}
|
|
242
258
|
|
|
243
259
|
/**
|
|
244
|
-
*
|
|
245
|
-
* @param {WebGLContextEvent | Event} event -
|
|
260
|
+
* Called when the WebGL context is restored.
|
|
261
|
+
* @param {WebGLContextEvent | Event} event - The WebGL context restore event.
|
|
246
262
|
*/
|
|
247
263
|
contextRestored(event) {
|
|
248
264
|
this.logger.info('contextRestored', event);
|
|
@@ -254,8 +270,8 @@ export class Game {
|
|
|
254
270
|
}
|
|
255
271
|
|
|
256
272
|
/**
|
|
257
|
-
*
|
|
258
|
-
* @param {number} time -
|
|
273
|
+
* Updates the game state.
|
|
274
|
+
* @param {number} time - The current timestamp.
|
|
259
275
|
*/
|
|
260
276
|
update(time) {
|
|
261
277
|
this.time.update(time);
|
|
@@ -278,7 +294,7 @@ export class Game {
|
|
|
278
294
|
}
|
|
279
295
|
|
|
280
296
|
/**
|
|
281
|
-
*
|
|
297
|
+
* Destroys the game and cleans up all resources.
|
|
282
298
|
*/
|
|
283
299
|
destroy() {
|
|
284
300
|
this.logger.info('destroy');
|
|
@@ -19,8 +19,10 @@ export class Pointer {
|
|
|
19
19
|
constructor(game, id, pointerMode) {
|
|
20
20
|
this.game = game;
|
|
21
21
|
this.id = id;
|
|
22
|
+
/** @type {number} */
|
|
22
23
|
this.type = POINTER;
|
|
23
24
|
this.exists = true;
|
|
25
|
+
/** @type {number} */
|
|
24
26
|
this.identifier = 0;
|
|
25
27
|
this.pointerId = null;
|
|
26
28
|
this.pointerMode = pointerMode || POINTER_CURSOR | POINTER_CONTACT;
|
|
@@ -28,27 +30,43 @@ export class Pointer {
|
|
|
28
30
|
this.button = null;
|
|
29
31
|
this._holdSent = false;
|
|
30
32
|
this._history = [];
|
|
33
|
+
/** @type {number} */
|
|
31
34
|
this._nextDrop = 0;
|
|
32
35
|
this._stateReset = false;
|
|
33
36
|
this.withinGame = false;
|
|
34
37
|
this.clientX = -1;
|
|
38
|
+
/** @type {number} */
|
|
35
39
|
this.clientY = -1;
|
|
40
|
+
/** @type {number} */
|
|
36
41
|
this.pageX = -1;
|
|
42
|
+
/** @type {number} */
|
|
37
43
|
this.pageY = -1;
|
|
44
|
+
/** @type {number} */
|
|
38
45
|
this.screenX = -1;
|
|
46
|
+
/** @type {number} */
|
|
39
47
|
this.screenY = -1;
|
|
48
|
+
/** @type {number} */
|
|
40
49
|
this.rawMovementX = 0;
|
|
50
|
+
/** @type {number} */
|
|
41
51
|
this.rawMovementY = 0;
|
|
52
|
+
/** @type {number} */
|
|
42
53
|
this.movementX = 0;
|
|
54
|
+
/** @type {number} */
|
|
43
55
|
this.movementY = 0;
|
|
56
|
+
/** @type {number} */
|
|
44
57
|
this.x = -1;
|
|
58
|
+
/** @type {number} */
|
|
45
59
|
this.y = -1;
|
|
46
60
|
this.isMouse = id === 0;
|
|
47
61
|
this.isDown = false;
|
|
48
62
|
this.isUp = true;
|
|
63
|
+
/** @type {number} */
|
|
49
64
|
this.timeDown = 0;
|
|
65
|
+
/** @type {number} */
|
|
50
66
|
this.timeUp = 0;
|
|
67
|
+
/** @type {number} */
|
|
51
68
|
this.previousTapTime = 0;
|
|
69
|
+
/** @type {number} */
|
|
52
70
|
this.totalTouches = 0;
|
|
53
71
|
this.msSinceLastClick = Number.MAX_VALUE;
|
|
54
72
|
this.targetObject = null;
|