@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
|
@@ -8,19 +8,22 @@ export const SORT_DESCENDING = 1;
|
|
|
8
8
|
|
|
9
9
|
export class Group extends DisplayObject {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param {import('../core/game.js').Game} game -
|
|
13
|
-
* @param {DisplayObject} parent -
|
|
14
|
-
* @param {string} name -
|
|
15
|
-
* @param {boolean} addToStage -
|
|
11
|
+
* Creates a new Group object.
|
|
12
|
+
* @param {import('../core/game.js').Game} game - The game instance this group belongs to.
|
|
13
|
+
* @param {DisplayObject} parent - The parent display object.
|
|
14
|
+
* @param {string} name - The name of this group.
|
|
15
|
+
* @param {boolean} addToStage - Whether to add this group to the stage.
|
|
16
16
|
*/
|
|
17
17
|
constructor(game, parent = null, name = null, addToStage = false) {
|
|
18
18
|
super(game);
|
|
19
|
+
/** @type {number} */
|
|
19
20
|
this.type = GROUP;
|
|
20
21
|
if (!parent) {
|
|
21
22
|
parent = game.world;
|
|
22
23
|
}
|
|
24
|
+
/** @type {string} */
|
|
23
25
|
this.name = name || 'group';
|
|
26
|
+
/** @type {number} */
|
|
24
27
|
this.z = 0;
|
|
25
28
|
if (addToStage) {
|
|
26
29
|
this.game.stage.addChild(this);
|
|
@@ -29,24 +32,34 @@ export class Group extends DisplayObject {
|
|
|
29
32
|
parent.addChild(this);
|
|
30
33
|
this.z = parent.children.length;
|
|
31
34
|
}
|
|
35
|
+
/** @type {boolean} */
|
|
32
36
|
this.ignoreDestroy = false;
|
|
37
|
+
/** @type {boolean} */
|
|
33
38
|
this.pendingDestroy = false;
|
|
34
39
|
this.classType = Image;
|
|
35
40
|
this.cursor = null;
|
|
41
|
+
/** @type {boolean} */
|
|
36
42
|
this.inputEnableChildren = false;
|
|
43
|
+
/** @type {Signal} */
|
|
37
44
|
this.onChildInputDown = new Signal();
|
|
45
|
+
/** @type {Signal} */
|
|
38
46
|
this.onChildInputUp = new Signal();
|
|
47
|
+
/** @type {Signal} */
|
|
39
48
|
this.onChildInputOver = new Signal();
|
|
49
|
+
/** @type {Signal} */
|
|
40
50
|
this.onChildInputOut = new Signal();
|
|
51
|
+
/** @type {Signal} */
|
|
41
52
|
this.onDestroy = new Signal();
|
|
53
|
+
/** @type {number} */
|
|
42
54
|
this.cursorIndex = 0;
|
|
55
|
+
/** @type {string} */
|
|
43
56
|
this._sortProperty = 'z';
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param {boolean} destroyChildren -
|
|
49
|
-
* @param {boolean} soft -
|
|
60
|
+
* Destroys this group and cleans up resources.
|
|
61
|
+
* @param {boolean} destroyChildren - Whether to destroy children as well.
|
|
62
|
+
* @param {boolean} soft - Whether to perform a soft destroy (leaving the group in the parent's children list).
|
|
50
63
|
*/
|
|
51
64
|
destroy(destroyChildren = true, soft = false) {
|
|
52
65
|
if (this.game === null || this.ignoreDestroy) {
|
|
@@ -67,11 +80,11 @@ export class Group extends DisplayObject {
|
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @param {DisplayObject} child -
|
|
72
|
-
* @param {boolean} silent -
|
|
73
|
-
* @param {number} index -
|
|
74
|
-
* @returns {DisplayObject}
|
|
83
|
+
* Adds a child to this group.
|
|
84
|
+
* @param {DisplayObject} child - The child to add.
|
|
85
|
+
* @param {boolean} silent - Whether to dispatch events.
|
|
86
|
+
* @param {number} index - The index to add the child at.
|
|
87
|
+
* @returns {DisplayObject} The added child.
|
|
75
88
|
*/
|
|
76
89
|
add(child, silent = false, index = -1) {
|
|
77
90
|
if (child.parent === this) {
|
|
@@ -97,19 +110,19 @@ export class Group extends DisplayObject {
|
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {DisplayObject} child -
|
|
102
|
-
* @param {number} index -
|
|
103
|
-
* @param {boolean} silent -
|
|
113
|
+
* Adds a child to this group at a specific index.
|
|
114
|
+
* @param {DisplayObject} child - The child to add.
|
|
115
|
+
* @param {number} index - The index to add the child at.
|
|
116
|
+
* @param {boolean} silent - Whether to dispatch events.
|
|
104
117
|
*/
|
|
105
118
|
addAt(child, index, silent) {
|
|
106
119
|
this.add(child, silent, index);
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param {number} index -
|
|
112
|
-
* @returns {DisplayObject}
|
|
123
|
+
* Gets a child at the specified index.
|
|
124
|
+
* @param {number} index - The index of the child to get.
|
|
125
|
+
* @returns {DisplayObject} The child at the specified index, or -1 if not found.
|
|
113
126
|
*/
|
|
114
127
|
getAt(index) {
|
|
115
128
|
if (index < 0 || index >= this.children.length) {
|
|
@@ -119,7 +132,7 @@ export class Group extends DisplayObject {
|
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
/**
|
|
122
|
-
*
|
|
135
|
+
* Updates the Z indices of all children in this group.
|
|
123
136
|
*/
|
|
124
137
|
updateZ() {
|
|
125
138
|
let i = this.children.length;
|
|
@@ -130,8 +143,8 @@ export class Group extends DisplayObject {
|
|
|
130
143
|
}
|
|
131
144
|
|
|
132
145
|
/**
|
|
133
|
-
*
|
|
134
|
-
* @returns {DisplayObject}
|
|
146
|
+
* Gets the next child in this group (with circular wrapping).
|
|
147
|
+
* @returns {DisplayObject} The next child, or null if no children exist.
|
|
135
148
|
*/
|
|
136
149
|
next() {
|
|
137
150
|
if (this.cursor) {
|
|
@@ -148,8 +161,8 @@ export class Group extends DisplayObject {
|
|
|
148
161
|
}
|
|
149
162
|
|
|
150
163
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @returns {DisplayObject}
|
|
164
|
+
* Gets the previous child in this group (with circular wrapping).
|
|
165
|
+
* @returns {DisplayObject} The previous child, or null if no children exist.
|
|
153
166
|
*/
|
|
154
167
|
previous() {
|
|
155
168
|
if (this.cursor) {
|
|
@@ -166,9 +179,9 @@ export class Group extends DisplayObject {
|
|
|
166
179
|
}
|
|
167
180
|
|
|
168
181
|
/**
|
|
169
|
-
*
|
|
170
|
-
* @param {DisplayObject} child1 -
|
|
171
|
-
* @param {DisplayObject} child2 -
|
|
182
|
+
* Swaps the positions of two children in this group.
|
|
183
|
+
* @param {DisplayObject} child1 - The first child to swap.
|
|
184
|
+
* @param {DisplayObject} child2 - The second child to swap.
|
|
172
185
|
*/
|
|
173
186
|
swap(child1, child2) {
|
|
174
187
|
this.swapChildren(child1, child2);
|
|
@@ -176,9 +189,9 @@ export class Group extends DisplayObject {
|
|
|
176
189
|
}
|
|
177
190
|
|
|
178
191
|
/**
|
|
179
|
-
*
|
|
180
|
-
* @param {DisplayObject} child -
|
|
181
|
-
* @returns {DisplayObject}
|
|
192
|
+
* Brings a child to the top of this group.
|
|
193
|
+
* @param {DisplayObject} child - The child to bring to the top.
|
|
194
|
+
* @returns {DisplayObject} The child that was brought to the top.
|
|
182
195
|
*/
|
|
183
196
|
bringToTop(child) {
|
|
184
197
|
if (child.parent === this && this.getIndex(child) < this.children.length) {
|
|
@@ -189,9 +202,9 @@ export class Group extends DisplayObject {
|
|
|
189
202
|
}
|
|
190
203
|
|
|
191
204
|
/**
|
|
192
|
-
*
|
|
193
|
-
* @param {DisplayObject} child -
|
|
194
|
-
* @returns {DisplayObject}
|
|
205
|
+
* Sends a child to the back of this group.
|
|
206
|
+
* @param {DisplayObject} child - The child to send to the back.
|
|
207
|
+
* @returns {DisplayObject} The child that was sent to the back.
|
|
195
208
|
*/
|
|
196
209
|
sendToBack(child) {
|
|
197
210
|
if (child.parent === this && this.getIndex(child) > 0) {
|
|
@@ -202,7 +215,7 @@ export class Group extends DisplayObject {
|
|
|
202
215
|
}
|
|
203
216
|
|
|
204
217
|
/**
|
|
205
|
-
*
|
|
218
|
+
* Reverses the order of children in this group.
|
|
206
219
|
*/
|
|
207
220
|
reverse() {
|
|
208
221
|
this.children.reverse();
|
|
@@ -210,16 +223,16 @@ export class Group extends DisplayObject {
|
|
|
210
223
|
}
|
|
211
224
|
|
|
212
225
|
/**
|
|
213
|
-
*
|
|
214
|
-
* @param {DisplayObject} child -
|
|
215
|
-
* @returns {number}
|
|
226
|
+
* Gets the index of a child in this group.
|
|
227
|
+
* @param {DisplayObject} child - The child to get the index of.
|
|
228
|
+
* @returns {number} The index of the child, or -1 if not found.
|
|
216
229
|
*/
|
|
217
230
|
getIndex(child) {
|
|
218
231
|
return this.children.indexOf(child);
|
|
219
232
|
}
|
|
220
233
|
|
|
221
234
|
/**
|
|
222
|
-
*
|
|
235
|
+
* Updates the Z indices of all children in this group before the update cycle.
|
|
223
236
|
*/
|
|
224
237
|
preUpdate() {
|
|
225
238
|
if (this.pendingDestroy) {
|
|
@@ -236,7 +249,7 @@ export class Group extends DisplayObject {
|
|
|
236
249
|
}
|
|
237
250
|
|
|
238
251
|
/**
|
|
239
|
-
*
|
|
252
|
+
* Updates all children in this group during the update cycle.
|
|
240
253
|
*/
|
|
241
254
|
update() {
|
|
242
255
|
let i = this.children.length;
|
|
@@ -247,7 +260,7 @@ export class Group extends DisplayObject {
|
|
|
247
260
|
}
|
|
248
261
|
|
|
249
262
|
/**
|
|
250
|
-
*
|
|
263
|
+
* Updates all children in this group after the update cycle.
|
|
251
264
|
*/
|
|
252
265
|
postUpdate() {
|
|
253
266
|
for (let i = 0; i < this.children.length; i += 1) {
|
|
@@ -256,11 +269,11 @@ export class Group extends DisplayObject {
|
|
|
256
269
|
}
|
|
257
270
|
|
|
258
271
|
/**
|
|
259
|
-
*
|
|
260
|
-
* @param {DisplayObject} child -
|
|
261
|
-
* @param {boolean} destroy -
|
|
262
|
-
* @param {boolean} silent -
|
|
263
|
-
* @returns {boolean}
|
|
272
|
+
* Removes a child from this group.
|
|
273
|
+
* @param {DisplayObject} child - The child to remove.
|
|
274
|
+
* @param {boolean} destroy - Whether to destroy the child after removing it.
|
|
275
|
+
* @param {boolean} silent - Whether to dispatch events.
|
|
276
|
+
* @returns {boolean} True if the child was removed, false otherwise.
|
|
264
277
|
*/
|
|
265
278
|
remove(child, destroy = true, silent = false) {
|
|
266
279
|
if (this.children.length === 0 || this.children.indexOf(child) === -1) {
|
|
@@ -281,10 +294,10 @@ export class Group extends DisplayObject {
|
|
|
281
294
|
}
|
|
282
295
|
|
|
283
296
|
/**
|
|
284
|
-
*
|
|
285
|
-
* @param {boolean} destroy -
|
|
286
|
-
* @param {boolean} silent -
|
|
287
|
-
* @param {boolean} destroyTexture -
|
|
297
|
+
* Removes all children from this group.
|
|
298
|
+
* @param {boolean} destroy - Whether to destroy children as well.
|
|
299
|
+
* @param {boolean} silent - Whether to dispatch events.
|
|
300
|
+
* @param {boolean} destroyTexture - Whether to destroy textures as well.
|
|
288
301
|
*/
|
|
289
302
|
removeAll(destroy = true, silent = false, destroyTexture = false) {
|
|
290
303
|
if (this.children.length === 0) {
|
|
@@ -9,41 +9,55 @@ import { Texture } from './webgl/texture.js';
|
|
|
9
9
|
|
|
10
10
|
export class Image extends DisplayObject {
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @param {import('../core/game.js').Game} game -
|
|
14
|
-
* @param {number} x -
|
|
15
|
-
* @param {number} y -
|
|
16
|
-
* @param {string} key -
|
|
17
|
-
* @param {string | number} frame -
|
|
12
|
+
* Creates a new Image instance.
|
|
13
|
+
* @param {import('../core/game.js').Game} game - The game instance this image belongs to.
|
|
14
|
+
* @param {number} x - The x position of the image.
|
|
15
|
+
* @param {number} y - The y position of the image.
|
|
16
|
+
* @param {string | number | Texture} key - The texture key or texture to use.
|
|
17
|
+
* @param {string | number} frame - The frame identifier (name or index) to use.
|
|
18
18
|
*/
|
|
19
19
|
constructor(game, x, y, key, frame = 0) {
|
|
20
20
|
super(game);
|
|
21
|
+
/** @type {number} */
|
|
21
22
|
this.type = IMAGE;
|
|
23
|
+
/** @type {boolean} */
|
|
22
24
|
this.renderable = true;
|
|
25
|
+
/** @type {string | number | Texture} */
|
|
23
26
|
this.key = key;
|
|
24
27
|
this.texture = window.PhaserRegistry.CACHE_MISSING_IMAGE;
|
|
25
28
|
/** @type {object} */
|
|
26
29
|
this.data = {};
|
|
30
|
+
/** @type {number} */
|
|
27
31
|
this._width = 0;
|
|
32
|
+
/** @type {number} */
|
|
28
33
|
this._height = 0;
|
|
34
|
+
/** @type {number} */
|
|
29
35
|
this.tint = 0xffffff;
|
|
36
|
+
/** @type {number} */
|
|
30
37
|
this.cachedTint = -1;
|
|
38
|
+
/** @type {Texture | null} */
|
|
39
|
+
this.tilingTexture = null;
|
|
40
|
+
/** @type {Texture | null} */
|
|
31
41
|
this.tintedTexture = null;
|
|
42
|
+
/** @type {number} */
|
|
32
43
|
this.blendMode = BLEND_NORMAL;
|
|
33
44
|
this.shader = null;
|
|
34
45
|
this._frame = null;
|
|
46
|
+
/** @type {boolean} */
|
|
35
47
|
this.pendingDestroy = false;
|
|
36
48
|
/* if (this.texture.baseTexture.hasLoaded) {
|
|
37
49
|
this.onTextureUpdate();
|
|
38
50
|
} */
|
|
39
51
|
this.position.setTo(x, y);
|
|
52
|
+
/** @type {EventManager} */
|
|
40
53
|
this.events = new EventManager(this);
|
|
54
|
+
/** @type {AnimationManager} */
|
|
41
55
|
this.animations = new AnimationManager(this);
|
|
42
56
|
this.loadTexture(key, frame);
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
/**
|
|
46
|
-
*
|
|
60
|
+
* Destroys this image and cleans up resources.
|
|
47
61
|
*/
|
|
48
62
|
destroy() {
|
|
49
63
|
this.game = null;
|
|
@@ -67,7 +81,7 @@ export class Image extends DisplayObject {
|
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
/**
|
|
70
|
-
*
|
|
84
|
+
* Called before the update cycle for this image.
|
|
71
85
|
*/
|
|
72
86
|
preUpdate() {
|
|
73
87
|
if (this.pendingDestroy) {
|
|
@@ -93,10 +107,10 @@ export class Image extends DisplayObject {
|
|
|
93
107
|
// LoadTexture
|
|
94
108
|
|
|
95
109
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {string | number | Texture} key -
|
|
98
|
-
* @param {string | number | null | undefined} frame -
|
|
99
|
-
* @param {boolean} stopAnimation -
|
|
110
|
+
* Loads a texture for this image.
|
|
111
|
+
* @param {string | number | Texture} key - The texture key or texture to use.
|
|
112
|
+
* @param {string | number | null | undefined} frame - The frame identifier (name or index) to use.
|
|
113
|
+
* @param {boolean} stopAnimation - Whether to stop the animation when changing textures.
|
|
100
114
|
*/
|
|
101
115
|
loadTexture(key, frame = 0, stopAnimation = true) {
|
|
102
116
|
if (key === PENDING_ATLAS) {
|
|
@@ -137,8 +151,8 @@ export class Image extends DisplayObject {
|
|
|
137
151
|
}
|
|
138
152
|
|
|
139
153
|
/**
|
|
140
|
-
*
|
|
141
|
-
* @param {import('../core/frame.js').Frame} frame -
|
|
154
|
+
* Sets the current frame of this image.
|
|
155
|
+
* @param {import('../core/frame.js').Frame} frame - The frame to set.
|
|
142
156
|
*/
|
|
143
157
|
setFrame(frame) {
|
|
144
158
|
this._frame = frame;
|
|
@@ -182,10 +196,10 @@ export class Image extends DisplayObject {
|
|
|
182
196
|
}
|
|
183
197
|
|
|
184
198
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param {DisplayObject} parent -
|
|
187
|
-
* @param {number} width -
|
|
188
|
-
* @param {number} height -
|
|
199
|
+
* Resizes the frame of this image.
|
|
200
|
+
* @param {DisplayObject} parent - The parent display object.
|
|
201
|
+
* @param {number} width - The new width of the frame.
|
|
202
|
+
* @param {number} height - The new height of the frame.
|
|
189
203
|
*/
|
|
190
204
|
resizeFrame(parent, width, height) {
|
|
191
205
|
this.texture.frame.resize(width, height);
|
|
@@ -193,7 +207,7 @@ export class Image extends DisplayObject {
|
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
/**
|
|
196
|
-
*
|
|
210
|
+
* Resets the frame of this image to its original frame.
|
|
197
211
|
*/
|
|
198
212
|
resetFrame() {
|
|
199
213
|
if (this._frame) {
|
|
@@ -202,30 +216,32 @@ export class Image extends DisplayObject {
|
|
|
202
216
|
}
|
|
203
217
|
|
|
204
218
|
/**
|
|
205
|
-
*
|
|
206
|
-
* @returns {number}
|
|
219
|
+
* Gets the current frame index of this image.
|
|
220
|
+
* @returns {number} The current frame index.
|
|
207
221
|
*/
|
|
208
222
|
get frame() {
|
|
209
223
|
return this.animations.frame;
|
|
210
224
|
}
|
|
211
225
|
|
|
212
226
|
/**
|
|
213
|
-
*
|
|
227
|
+
* Sets the current frame index of this image.
|
|
228
|
+
* @param {number} value - The new frame index to set.
|
|
214
229
|
*/
|
|
215
230
|
set frame(value) {
|
|
216
231
|
this.animations.frame = value;
|
|
217
232
|
}
|
|
218
233
|
|
|
219
234
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @returns {string}
|
|
235
|
+
* Gets the current frame name of this image.
|
|
236
|
+
* @returns {string} The current frame name.
|
|
222
237
|
*/
|
|
223
238
|
get frameName() {
|
|
224
239
|
return this.animations.frameName;
|
|
225
240
|
}
|
|
226
241
|
|
|
227
242
|
/**
|
|
228
|
-
*
|
|
243
|
+
* Sets the current frame name of this image.
|
|
244
|
+
* @param {string} value - The new frame name to set.
|
|
229
245
|
*/
|
|
230
246
|
set frameName(value) {
|
|
231
247
|
this.animations.frameName = value;
|
|
@@ -234,9 +250,9 @@ export class Image extends DisplayObject {
|
|
|
234
250
|
// Crop
|
|
235
251
|
|
|
236
252
|
/**
|
|
237
|
-
*
|
|
238
|
-
* @param {Rectangle} rect -
|
|
239
|
-
* @param {boolean} copy -
|
|
253
|
+
* Crops the texture of this image.
|
|
254
|
+
* @param {Rectangle} rect - The rectangle to crop to.
|
|
255
|
+
* @param {boolean} copy - Whether to copy the rect or use it directly.
|
|
240
256
|
*/
|
|
241
257
|
crop(rect, copy = false) {
|
|
242
258
|
if (rect) {
|
|
@@ -256,7 +272,7 @@ export class Image extends DisplayObject {
|
|
|
256
272
|
}
|
|
257
273
|
|
|
258
274
|
/**
|
|
259
|
-
*
|
|
275
|
+
* Updates the crop rectangle of this image.
|
|
260
276
|
*/
|
|
261
277
|
updateCrop() {
|
|
262
278
|
if (!this.cropRect) {
|
|
@@ -288,15 +304,16 @@ export class Image extends DisplayObject {
|
|
|
288
304
|
}
|
|
289
305
|
|
|
290
306
|
/**
|
|
291
|
-
*
|
|
292
|
-
* @returns {number}
|
|
307
|
+
* Gets the width of this image.
|
|
308
|
+
* @returns {number} The width in pixels.
|
|
293
309
|
*/
|
|
294
310
|
get width() {
|
|
295
311
|
return this.scale.x * this.texture.frame.width;
|
|
296
312
|
}
|
|
297
313
|
|
|
298
314
|
/**
|
|
299
|
-
*
|
|
315
|
+
* Sets the width of this image.
|
|
316
|
+
* @param {number} value - The new width in pixels.
|
|
300
317
|
*/
|
|
301
318
|
set width(value) {
|
|
302
319
|
this.scale.x = value / this.texture.frame.width;
|
|
@@ -304,15 +321,16 @@ export class Image extends DisplayObject {
|
|
|
304
321
|
}
|
|
305
322
|
|
|
306
323
|
/**
|
|
307
|
-
*
|
|
308
|
-
* @returns {number}
|
|
324
|
+
* Gets the height of this image.
|
|
325
|
+
* @returns {number} The height in pixels.
|
|
309
326
|
*/
|
|
310
327
|
get height() {
|
|
311
328
|
return this.scale.y * this.texture.frame.height;
|
|
312
329
|
}
|
|
313
330
|
|
|
314
331
|
/**
|
|
315
|
-
*
|
|
332
|
+
* Sets the height of this image.
|
|
333
|
+
* @param {number} value - The new height in pixels.
|
|
316
334
|
*/
|
|
317
335
|
set height(value) {
|
|
318
336
|
this.scale.y = value / this.texture.frame.height;
|
|
@@ -320,7 +338,7 @@ export class Image extends DisplayObject {
|
|
|
320
338
|
}
|
|
321
339
|
|
|
322
340
|
/**
|
|
323
|
-
*
|
|
341
|
+
* Called when the texture of this image is updated.
|
|
324
342
|
*/
|
|
325
343
|
onTextureUpdate() {
|
|
326
344
|
// so if _width is 0 then width was not set..
|
|
@@ -333,44 +351,44 @@ export class Image extends DisplayObject {
|
|
|
333
351
|
}
|
|
334
352
|
|
|
335
353
|
/**
|
|
336
|
-
*
|
|
337
|
-
* @param {Texture} texture -
|
|
338
|
-
* @param {boolean} destroyBase -
|
|
354
|
+
* Sets the texture for this image.
|
|
355
|
+
* @param {Texture} texture - The new texture to set.
|
|
356
|
+
* @param {boolean} destroyBase - Whether to destroy the base texture.
|
|
339
357
|
*/
|
|
340
358
|
setTexture(texture, destroyBase = false) {
|
|
341
359
|
setTexture(this, texture, destroyBase);
|
|
342
360
|
}
|
|
343
361
|
|
|
344
362
|
/**
|
|
345
|
-
*
|
|
346
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
347
|
-
* @returns {Rectangle}
|
|
363
|
+
* Gets the bounds of this image.
|
|
364
|
+
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
365
|
+
* @returns {Rectangle} The bounds rectangle of this image.
|
|
348
366
|
*/
|
|
349
367
|
getBounds(matrix = null) {
|
|
350
368
|
return getBounds(this, matrix);
|
|
351
369
|
}
|
|
352
370
|
|
|
353
371
|
/**
|
|
354
|
-
*
|
|
355
|
-
* @returns {Rectangle}
|
|
372
|
+
* Gets the local bounds of this image.
|
|
373
|
+
* @returns {Rectangle} The local bounds rectangle of this image.
|
|
356
374
|
*/
|
|
357
375
|
getLocalBounds() {
|
|
358
376
|
return getLocalBounds(this);
|
|
359
377
|
}
|
|
360
378
|
|
|
361
379
|
/**
|
|
362
|
-
*
|
|
363
|
-
* @param {object} renderSession -
|
|
364
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
380
|
+
* Renders this image using WebGL.
|
|
381
|
+
* @param {object} renderSession - The WebGL rendering session.
|
|
382
|
+
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
365
383
|
*/
|
|
366
384
|
renderWebGL(renderSession, matrix = null) {
|
|
367
385
|
renderWebGL(this, renderSession, matrix);
|
|
368
386
|
}
|
|
369
387
|
|
|
370
388
|
/**
|
|
371
|
-
*
|
|
372
|
-
* @param {object} renderSession -
|
|
373
|
-
* @param {import('../geom/matrix.js').Matrix} matrix -
|
|
389
|
+
* Renders this image using Canvas.
|
|
390
|
+
* @param {object} renderSession - The Canvas rendering session.
|
|
391
|
+
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
374
392
|
*/
|
|
375
393
|
renderCanvas(renderSession, matrix = null) {
|
|
376
394
|
renderCanvas(this, renderSession, matrix);
|
|
@@ -2,8 +2,8 @@ import { DisplayObject } from './display_object.js';
|
|
|
2
2
|
|
|
3
3
|
export class SpriteBatch extends DisplayObject {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {import('../core/game.js').Game} game -
|
|
5
|
+
* Creates a new SpriteBatch object.
|
|
6
|
+
* @param {import('../core/game.js').Game} game - The game instance.
|
|
7
7
|
*/
|
|
8
8
|
constructor(game) {
|
|
9
9
|
super(game);
|
|
@@ -3,10 +3,10 @@ import { getIdentityMatrix } from '../geom/util/matrix.js';
|
|
|
3
3
|
import { getTintedTexture } from './canvas/tinter.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {import('./image.js').Image} target -
|
|
8
|
-
* @param {import('./webgl/texture.js').Texture} texture -
|
|
9
|
-
* @param {boolean} destroyBase -
|
|
6
|
+
* Sets the texture of a sprite.
|
|
7
|
+
* @param {import('./image.js').Image} target - The target image to set the texture on.
|
|
8
|
+
* @param {import('./webgl/texture.js').Texture} texture - The new texture to set.
|
|
9
|
+
* @param {boolean} destroyBase - Whether to destroy the base texture.
|
|
10
10
|
*/
|
|
11
11
|
export const setTexture = (target, texture, destroyBase = false) => {
|
|
12
12
|
if (destroyBase) {
|
|
@@ -19,10 +19,10 @@ export const setTexture = (target, texture, destroyBase = false) => {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {import('./image.js').Image} target -
|
|
24
|
-
* @param {object} matrix -
|
|
25
|
-
* @returns {import('../geom/rectangle.js').Rectangle}
|
|
22
|
+
* Gets the bounds of a sprite.
|
|
23
|
+
* @param {import('./image.js').Image} target - The target image to get bounds for.
|
|
24
|
+
* @param {object} matrix - The transformation matrix.
|
|
25
|
+
* @returns {import('../geom/rectangle.js').Rectangle} The bounds rectangle.
|
|
26
26
|
*/
|
|
27
27
|
export const getBounds = (target, matrix = null) => {
|
|
28
28
|
// TODO verify
|
|
@@ -102,9 +102,9 @@ export const getBounds = (target, matrix = null) => {
|
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
*
|
|
106
|
-
* @param {import('./image.js').Image} target -
|
|
107
|
-
* @returns {import('../geom/rectangle.js').Rectangle}
|
|
105
|
+
* Gets the local bounds of a sprite.
|
|
106
|
+
* @param {import('./image.js').Image} target - The target image to get local bounds for.
|
|
107
|
+
* @returns {import('../geom/rectangle.js').Rectangle} The local bounds rectangle.
|
|
108
108
|
*/
|
|
109
109
|
export const getLocalBounds = (target) => {
|
|
110
110
|
const matrixCache = target.worldTransform;
|
|
@@ -122,10 +122,10 @@ export const getLocalBounds = (target) => {
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @param {import('./image.js').Image} target -
|
|
127
|
-
* @param {object} renderSession -
|
|
128
|
-
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix -
|
|
125
|
+
* Renders a sprite using WebGL.
|
|
126
|
+
* @param {import('./image.js').Image} target - The target image to render.
|
|
127
|
+
* @param {object} renderSession - The render session object.
|
|
128
|
+
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix - The transformation matrix.
|
|
129
129
|
*/
|
|
130
130
|
export const renderWebGL = (target, renderSession, matrix = null) => {
|
|
131
131
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
@@ -171,10 +171,10 @@ export const renderWebGL = (target, renderSession, matrix = null) => {
|
|
|
171
171
|
};
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @param {import('./image.js').Image} target -
|
|
176
|
-
* @param {object} renderSession -
|
|
177
|
-
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix -
|
|
174
|
+
* Renders a sprite using Canvas.
|
|
175
|
+
* @param {import('./image.js').Image} target - The target image to render.
|
|
176
|
+
* @param {object} renderSession - The render session object.
|
|
177
|
+
* @param {import('../geom/matrix.js').Matrix | null | undefined} matrix - The transformation matrix.
|
|
178
178
|
*/
|
|
179
179
|
export const renderCanvas = (target, renderSession, matrix = null) => {
|
|
180
180
|
// If the sprite is not visible or the alpha is 0 then no need to render this element
|