@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
|
@@ -7,8 +7,8 @@ import { renderCanvas, renderWebGL } from './sprite_util.js';
|
|
|
7
7
|
|
|
8
8
|
export class DisplayObject {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* @param {import('../core/game.js').Game} game -
|
|
10
|
+
* Creates a new DisplayObject instance.
|
|
11
|
+
* @param {import('../core/game.js').Game} game - The game instance this display object belongs to.
|
|
12
12
|
*/
|
|
13
13
|
constructor(game) {
|
|
14
14
|
/** @type {boolean} */
|
|
@@ -69,7 +69,7 @@ export class DisplayObject {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Destroys this display object and cleans up resources.
|
|
73
73
|
*/
|
|
74
74
|
destroy() {
|
|
75
75
|
if (this.children) {
|
|
@@ -103,20 +103,20 @@ export class DisplayObject {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
107
|
-
* @param {DisplayObject} child -
|
|
108
|
-
* @returns {DisplayObject}
|
|
106
|
+
* Adds a child display object to this container.
|
|
107
|
+
* @param {DisplayObject} child - The child display object to add.
|
|
108
|
+
* @returns {DisplayObject} The added child display object.
|
|
109
109
|
*/
|
|
110
110
|
addChild(child) {
|
|
111
111
|
return this.addChildAt(child, this.children.length);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {DisplayObject} child -
|
|
117
|
-
* @param {number} index -
|
|
118
|
-
* @returns {DisplayObject}
|
|
119
|
-
* @throws {Error}
|
|
115
|
+
* Adds a child display object at a specific index in the children list.
|
|
116
|
+
* @param {DisplayObject} child - The child display object to add.
|
|
117
|
+
* @param {number} index - The index to insert the child at.
|
|
118
|
+
* @returns {DisplayObject} The added child display object.
|
|
119
|
+
* @throws {Error} If the index is out of bounds.
|
|
120
120
|
*/
|
|
121
121
|
addChildAt(child, index) {
|
|
122
122
|
if (index >= 0 && index <= this.children.length) {
|
|
@@ -131,10 +131,10 @@ export class DisplayObject {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
*
|
|
135
|
-
* @param {DisplayObject} child -
|
|
136
|
-
* @param {DisplayObject} child2 -
|
|
137
|
-
* @throws {Error}
|
|
134
|
+
* Swaps the positions of two child display objects.
|
|
135
|
+
* @param {DisplayObject} child - The first child display object.
|
|
136
|
+
* @param {DisplayObject} child2 - The second child display object.
|
|
137
|
+
* @throws {Error} If either child is not a child of this container.
|
|
138
138
|
*/
|
|
139
139
|
swapChildren(child, child2) {
|
|
140
140
|
if (child === child2) {
|
|
@@ -150,10 +150,10 @@ export class DisplayObject {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @param {DisplayObject} child -
|
|
155
|
-
* @returns {number}
|
|
156
|
-
* @throws {Error}
|
|
153
|
+
* Gets the index of a child display object in the children list.
|
|
154
|
+
* @param {DisplayObject} child - The child display object to find.
|
|
155
|
+
* @returns {number} The index of the child in the children list.
|
|
156
|
+
* @throws {Error} If the child is not a child of this container.
|
|
157
157
|
*/
|
|
158
158
|
getChildIndex(child) {
|
|
159
159
|
const index = this.children.indexOf(child);
|
|
@@ -164,10 +164,10 @@ export class DisplayObject {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
*
|
|
168
|
-
* @param {DisplayObject} child -
|
|
169
|
-
* @param {number} index -
|
|
170
|
-
* @throws {Error}
|
|
167
|
+
* Sets the index of a child display object in the children list.
|
|
168
|
+
* @param {DisplayObject} child - The child display object to move.
|
|
169
|
+
* @param {number} index - The new index for the child.
|
|
170
|
+
* @throws {Error} If the index is out of bounds.
|
|
171
171
|
*/
|
|
172
172
|
setChildIndex(child, index) {
|
|
173
173
|
if (index < 0 || index >= this.children.length) {
|
|
@@ -179,10 +179,10 @@ export class DisplayObject {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @param {number} index -
|
|
184
|
-
* @returns {DisplayObject}
|
|
185
|
-
* @throws {Error}
|
|
182
|
+
* Gets a child display object at a specific index.
|
|
183
|
+
* @param {number} index - The index of the child to get.
|
|
184
|
+
* @returns {DisplayObject} The child display object at the specified index.
|
|
185
|
+
* @throws {Error} If the index is out of bounds.
|
|
186
186
|
*/
|
|
187
187
|
getChildAt(index) {
|
|
188
188
|
if (index < 0 || index >= this.children.length) {
|
|
@@ -196,9 +196,9 @@ export class DisplayObject {
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @param {DisplayObject} child -
|
|
201
|
-
* @returns {DisplayObject}
|
|
199
|
+
* Removes a child display object from this container.
|
|
200
|
+
* @param {DisplayObject} child - The child display object to remove.
|
|
201
|
+
* @returns {DisplayObject} The removed child display object.
|
|
202
202
|
*/
|
|
203
203
|
removeChild(child) {
|
|
204
204
|
const index = this.children.indexOf(child);
|
|
@@ -209,9 +209,9 @@ export class DisplayObject {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
*
|
|
213
|
-
* @param {number} index -
|
|
214
|
-
* @returns {DisplayObject}
|
|
212
|
+
* Removes a child display object at a specific index.
|
|
213
|
+
* @param {number} index - The index of the child to remove.
|
|
214
|
+
* @returns {DisplayObject} The removed child display object.
|
|
215
215
|
*/
|
|
216
216
|
removeChildAt(index) {
|
|
217
217
|
const child = this.getChildAt(index);
|
|
@@ -223,11 +223,11 @@ export class DisplayObject {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
|
-
*
|
|
227
|
-
* @param {number} beginIndex -
|
|
228
|
-
* @param {number} endIndex -
|
|
229
|
-
* @returns {DisplayObject[]}
|
|
230
|
-
* @throws {Error}
|
|
226
|
+
* Removes a range of child display objects from this container.
|
|
227
|
+
* @param {number} beginIndex - The starting index of the range to remove.
|
|
228
|
+
* @param {number} endIndex - The ending index (exclusive) of the range to remove.
|
|
229
|
+
* @returns {DisplayObject[]} The array of removed child display objects.
|
|
230
|
+
* @throws {Error} If the range is invalid.
|
|
231
231
|
*/
|
|
232
232
|
removeChildren(beginIndex, endIndex) {
|
|
233
233
|
if (beginIndex === undefined) {
|
|
@@ -252,9 +252,9 @@ export class DisplayObject {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
|
-
*
|
|
256
|
-
* @param {DisplayObject | null | undefined} parent -
|
|
257
|
-
* @returns {DisplayObject}
|
|
255
|
+
* Updates the world transform of this display object and its children.
|
|
256
|
+
* @param {DisplayObject | null | undefined} parent - The parent display object to use for the world transform calculation.
|
|
257
|
+
* @returns {DisplayObject} This DisplayObject instance for chaining.
|
|
258
258
|
*/
|
|
259
259
|
updateTransform(parent = null) {
|
|
260
260
|
if (!parent && !this.parent) {
|
|
@@ -340,9 +340,9 @@ export class DisplayObject {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
/**
|
|
343
|
-
*
|
|
344
|
-
* @param {DisplayObject} targetCoordinateSpace -
|
|
345
|
-
* @returns {Rectangle}
|
|
343
|
+
* Gets the bounds of this display object in world coordinates.
|
|
344
|
+
* @param {DisplayObject} targetCoordinateSpace - The coordinate space to calculate bounds in.
|
|
345
|
+
* @returns {Rectangle} The bounds rectangle of this display object.
|
|
346
346
|
*/
|
|
347
347
|
getBounds(targetCoordinateSpace) {
|
|
348
348
|
const isTargetCoordinateSpaceDisplayObject = targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
|
|
@@ -442,17 +442,17 @@ export class DisplayObject {
|
|
|
442
442
|
}
|
|
443
443
|
|
|
444
444
|
/**
|
|
445
|
-
*
|
|
446
|
-
* @returns {Rectangle}
|
|
445
|
+
* Gets the bounds of this display object in local coordinates.
|
|
446
|
+
* @returns {Rectangle} The bounds rectangle of this display object in local space.
|
|
447
447
|
*/
|
|
448
448
|
getLocalBounds() {
|
|
449
449
|
return this.getBounds(this);
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
/**
|
|
453
|
-
*
|
|
454
|
-
* @param {DisplayObject} child -
|
|
455
|
-
* @returns {boolean}
|
|
453
|
+
* Checks if a child display object is contained within this container.
|
|
454
|
+
* @param {DisplayObject} child - The child display object to check.
|
|
455
|
+
* @returns {boolean} True if the child is contained within this container, false otherwise.
|
|
456
456
|
*/
|
|
457
457
|
contains(child) {
|
|
458
458
|
if (!child) {
|
|
@@ -465,8 +465,8 @@ export class DisplayObject {
|
|
|
465
465
|
}
|
|
466
466
|
|
|
467
467
|
/**
|
|
468
|
-
*
|
|
469
|
-
* @param {object} renderSession -
|
|
468
|
+
* Renders this display object using WebGL.
|
|
469
|
+
* @param {object} renderSession - The WebGL rendering session.
|
|
470
470
|
*/
|
|
471
471
|
renderWebGL(renderSession) {
|
|
472
472
|
if (!this.visible || this.alpha <= 0) {
|
|
@@ -499,8 +499,8 @@ export class DisplayObject {
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
/**
|
|
502
|
-
*
|
|
503
|
-
* @param {object} renderSession -
|
|
502
|
+
* Renders this display object using Canvas.
|
|
503
|
+
* @param {object} renderSession - The Canvas rendering session.
|
|
504
504
|
*/
|
|
505
505
|
renderCanvas(renderSession) {
|
|
506
506
|
if (!this.visible || this.alpha <= 0) {
|
|
@@ -518,29 +518,29 @@ export class DisplayObject {
|
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
/**
|
|
521
|
-
*
|
|
521
|
+
* Called before the update cycle for this display object.
|
|
522
522
|
*/
|
|
523
523
|
preUpdate() {
|
|
524
524
|
// override
|
|
525
525
|
}
|
|
526
526
|
|
|
527
527
|
/**
|
|
528
|
-
*
|
|
528
|
+
* Called during the update cycle for this display object.
|
|
529
529
|
*/
|
|
530
530
|
update() {
|
|
531
531
|
// override
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
/**
|
|
535
|
-
*
|
|
535
|
+
* Called after the update cycle for this display object.
|
|
536
536
|
*/
|
|
537
537
|
postUpdate() {
|
|
538
538
|
// override
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
/**
|
|
542
|
-
*
|
|
543
|
-
* @throws {Error}
|
|
542
|
+
* Generates a texture for this display object.
|
|
543
|
+
* @throws {Error} This method is not implemented yet.
|
|
544
544
|
*/
|
|
545
545
|
generateTexture() {
|
|
546
546
|
// TODO
|
|
@@ -548,9 +548,9 @@ export class DisplayObject {
|
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
/**
|
|
551
|
-
*
|
|
552
|
-
* @param {Point} position -
|
|
553
|
-
* @returns {Point}
|
|
551
|
+
* Converts a local position to global (world) coordinates.
|
|
552
|
+
* @param {Point} position - The local position to convert.
|
|
553
|
+
* @returns {Point} The converted global position.
|
|
554
554
|
*/
|
|
555
555
|
toGlobal(position) {
|
|
556
556
|
this.updateTransform();
|
|
@@ -558,10 +558,10 @@ export class DisplayObject {
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
|
-
*
|
|
562
|
-
* @param {Point} position -
|
|
563
|
-
* @param {DisplayObject} from -
|
|
564
|
-
* @returns {Point}
|
|
561
|
+
* Converts a global (world) position to local coordinates.
|
|
562
|
+
* @param {Point} position - The global position to convert.
|
|
563
|
+
* @param {DisplayObject} from - The display object to convert from (defaults to this).
|
|
564
|
+
* @returns {Point} The converted local position.
|
|
565
565
|
*/
|
|
566
566
|
toLocal(position, from) {
|
|
567
567
|
if (from) {
|
|
@@ -572,8 +572,8 @@ export class DisplayObject {
|
|
|
572
572
|
}
|
|
573
573
|
|
|
574
574
|
/**
|
|
575
|
-
*
|
|
576
|
-
* @param {object} renderSession -
|
|
575
|
+
* Renders a cached sprite for this display object.
|
|
576
|
+
* @param {object} renderSession - The rendering session.
|
|
577
577
|
*/
|
|
578
578
|
renderCachedSprite(renderSession) {
|
|
579
579
|
if (!this._cachedSprite) {
|
|
@@ -588,14 +588,14 @@ export class DisplayObject {
|
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
/**
|
|
591
|
-
*
|
|
591
|
+
* Generates a cached sprite for this display object.
|
|
592
592
|
*/
|
|
593
593
|
generateCachedSprite() {
|
|
594
594
|
// TODO
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
/**
|
|
598
|
-
*
|
|
598
|
+
* Destroys the cached sprite for this display object.
|
|
599
599
|
*/
|
|
600
600
|
destroyCachedSprite() {
|
|
601
601
|
if (!this._cachedSprite) {
|
|
@@ -608,15 +608,16 @@ export class DisplayObject {
|
|
|
608
608
|
// GETTER SETTER
|
|
609
609
|
|
|
610
610
|
/**
|
|
611
|
-
*
|
|
612
|
-
* @returns {number}
|
|
611
|
+
* Gets the width of this display object.
|
|
612
|
+
* @returns {number} The width in pixels.
|
|
613
613
|
*/
|
|
614
614
|
get width() {
|
|
615
615
|
return this.getLocalBounds().width * this.scale.x;
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
/**
|
|
619
|
-
*
|
|
619
|
+
* Sets the width of this display object.
|
|
620
|
+
* @param {number} value - The new width in pixels.
|
|
620
621
|
*/
|
|
621
622
|
set width(value) {
|
|
622
623
|
const width = this.getLocalBounds().width;
|
|
@@ -629,15 +630,16 @@ export class DisplayObject {
|
|
|
629
630
|
}
|
|
630
631
|
|
|
631
632
|
/**
|
|
632
|
-
*
|
|
633
|
-
* @returns {number}
|
|
633
|
+
* Gets the height of this display object.
|
|
634
|
+
* @returns {number} The height in pixels.
|
|
634
635
|
*/
|
|
635
636
|
get height() {
|
|
636
637
|
return this.getLocalBounds().height * this.scale.y;
|
|
637
638
|
}
|
|
638
639
|
|
|
639
640
|
/**
|
|
640
|
-
*
|
|
641
|
+
* Sets the height of this display object.
|
|
642
|
+
* @param {number} value - The new height in pixels.
|
|
641
643
|
*/
|
|
642
644
|
set height(value) {
|
|
643
645
|
const height = this.getLocalBounds().height;
|
|
@@ -650,38 +652,40 @@ export class DisplayObject {
|
|
|
650
652
|
}
|
|
651
653
|
|
|
652
654
|
/**
|
|
653
|
-
*
|
|
654
|
-
* @returns {number}
|
|
655
|
+
* Gets the x position of this display object.
|
|
656
|
+
* @returns {number} The x position in pixels.
|
|
655
657
|
*/
|
|
656
658
|
get x() {
|
|
657
659
|
return this.position.x;
|
|
658
660
|
}
|
|
659
661
|
|
|
660
662
|
/**
|
|
661
|
-
*
|
|
663
|
+
* Sets the x position of this display object.
|
|
664
|
+
* @param {number} value - The new x position in pixels.
|
|
662
665
|
*/
|
|
663
666
|
set x(value) {
|
|
664
667
|
this.position.x = value;
|
|
665
668
|
}
|
|
666
669
|
|
|
667
670
|
/**
|
|
668
|
-
*
|
|
669
|
-
* @returns {number}
|
|
671
|
+
* Gets the y position of this display object.
|
|
672
|
+
* @returns {number} The y position in pixels.
|
|
670
673
|
*/
|
|
671
674
|
get y() {
|
|
672
675
|
return this.position.y;
|
|
673
676
|
}
|
|
674
677
|
|
|
675
678
|
/**
|
|
676
|
-
*
|
|
679
|
+
* Sets the y position of this display object.
|
|
680
|
+
* @param {number} value - The new y position in pixels.
|
|
677
681
|
*/
|
|
678
682
|
set y(value) {
|
|
679
683
|
this.position.y = value;
|
|
680
684
|
}
|
|
681
685
|
|
|
682
686
|
/**
|
|
683
|
-
*
|
|
684
|
-
* @returns {boolean}
|
|
687
|
+
* Gets whether this display object is visible in the world.
|
|
688
|
+
* @returns {boolean} True if the object is visible, false otherwise.
|
|
685
689
|
*/
|
|
686
690
|
get worldVisible() {
|
|
687
691
|
if (!this.visible) {
|
|
@@ -703,15 +707,16 @@ export class DisplayObject {
|
|
|
703
707
|
// MASK
|
|
704
708
|
|
|
705
709
|
/**
|
|
706
|
-
*
|
|
707
|
-
* @returns {import('./graphics.js').Graphics}
|
|
710
|
+
* Gets the mask for this display object.
|
|
711
|
+
* @returns {import('./graphics.js').Graphics} The mask object or null if none is set.
|
|
708
712
|
*/
|
|
709
713
|
get mask() {
|
|
710
714
|
return this._mask;
|
|
711
715
|
}
|
|
712
716
|
|
|
713
717
|
/**
|
|
714
|
-
*
|
|
718
|
+
* Sets the mask for this display object.
|
|
719
|
+
* @param {import('./graphics.js').Graphics} value - The mask object to set, or null to remove the mask.
|
|
715
720
|
*/
|
|
716
721
|
set mask(value) {
|
|
717
722
|
if (this._mask) {
|
|
@@ -726,106 +731,112 @@ export class DisplayObject {
|
|
|
726
731
|
// BOUNDS
|
|
727
732
|
|
|
728
733
|
/**
|
|
729
|
-
*
|
|
730
|
-
* @returns {number}
|
|
734
|
+
* Gets the x offset for this display object (based on anchor point).
|
|
735
|
+
* @returns {number} The x offset in pixels.
|
|
731
736
|
*/
|
|
732
737
|
get offsetX() {
|
|
733
738
|
return this.anchor.x * this.width;
|
|
734
739
|
}
|
|
735
740
|
|
|
736
741
|
/**
|
|
737
|
-
*
|
|
738
|
-
* @returns {number}
|
|
742
|
+
* Gets the y offset for this display object (based on anchor point).
|
|
743
|
+
* @returns {number} The y offset in pixels.
|
|
739
744
|
*/
|
|
740
745
|
get offsetY() {
|
|
741
746
|
return this.anchor.y * this.height;
|
|
742
747
|
}
|
|
743
748
|
|
|
744
749
|
/**
|
|
745
|
-
*
|
|
746
|
-
* @returns {number}
|
|
750
|
+
* Gets the center x position of this display object.
|
|
751
|
+
* @returns {number} The center x position in pixels.
|
|
747
752
|
*/
|
|
748
753
|
get centerX() {
|
|
749
754
|
return this.x - this.offsetX + this.width * 0.5;
|
|
750
755
|
}
|
|
751
756
|
|
|
752
757
|
/**
|
|
753
|
-
*
|
|
758
|
+
* Sets the center x position of this display object.
|
|
759
|
+
* @param {number} value - The new center x position in pixels.
|
|
754
760
|
*/
|
|
755
761
|
set centerX(value) {
|
|
756
762
|
this.x = value + this.offsetX - this.width * 0.5;
|
|
757
763
|
}
|
|
758
764
|
|
|
759
765
|
/**
|
|
760
|
-
*
|
|
761
|
-
* @returns {number}
|
|
766
|
+
* Gets the center y position of this display object.
|
|
767
|
+
* @returns {number} The center y position in pixels.
|
|
762
768
|
*/
|
|
763
769
|
get centerY() {
|
|
764
770
|
return this.y - this.offsetY + this.height * 0.5;
|
|
765
771
|
}
|
|
766
772
|
|
|
767
773
|
/**
|
|
768
|
-
*
|
|
774
|
+
* Sets the center y position of this display object.
|
|
775
|
+
* @param {number} value - The new center y position in pixels.
|
|
769
776
|
*/
|
|
770
777
|
set centerY(value) {
|
|
771
778
|
this.y = value + this.offsetY - this.height * 0.5;
|
|
772
779
|
}
|
|
773
780
|
|
|
774
781
|
/**
|
|
775
|
-
*
|
|
776
|
-
* @returns {number}
|
|
782
|
+
* Gets the left x position of this display object.
|
|
783
|
+
* @returns {number} The left x position in pixels.
|
|
777
784
|
*/
|
|
778
785
|
get left() {
|
|
779
786
|
return this.x - this.offsetX;
|
|
780
787
|
}
|
|
781
788
|
|
|
782
789
|
/**
|
|
783
|
-
*
|
|
790
|
+
* Sets the left x position of this display object.
|
|
791
|
+
* @param {number} value - The new left x position in pixels.
|
|
784
792
|
*/
|
|
785
793
|
set left(value) {
|
|
786
794
|
this.x = value + this.offsetX;
|
|
787
795
|
}
|
|
788
796
|
|
|
789
797
|
/**
|
|
790
|
-
*
|
|
791
|
-
* @returns {number}
|
|
798
|
+
* Gets the right x position of this display object.
|
|
799
|
+
* @returns {number} The right x position in pixels.
|
|
792
800
|
*/
|
|
793
801
|
get right() {
|
|
794
802
|
return this.x + this.width - this.offsetX;
|
|
795
803
|
}
|
|
796
804
|
|
|
797
805
|
/**
|
|
798
|
-
*
|
|
806
|
+
* Sets the right x position of this display object.
|
|
807
|
+
* @param {number} value - The new right x position in pixels.
|
|
799
808
|
*/
|
|
800
809
|
set right(value) {
|
|
801
810
|
this.x = value - this.width + this.offsetX;
|
|
802
811
|
}
|
|
803
812
|
|
|
804
813
|
/**
|
|
805
|
-
*
|
|
806
|
-
* @returns {number}
|
|
814
|
+
* Gets the top y position of this display object.
|
|
815
|
+
* @returns {number} The top y position in pixels.
|
|
807
816
|
*/
|
|
808
817
|
get top() {
|
|
809
818
|
return this.y - this.offsetY;
|
|
810
819
|
}
|
|
811
820
|
|
|
812
821
|
/**
|
|
813
|
-
*
|
|
822
|
+
* Sets the top y position of this display object.
|
|
823
|
+
* @param {number} value - The new top y position in pixels.
|
|
814
824
|
*/
|
|
815
825
|
set top(value) {
|
|
816
826
|
this.y = value + this.offsetY;
|
|
817
827
|
}
|
|
818
828
|
|
|
819
829
|
/**
|
|
820
|
-
*
|
|
821
|
-
* @returns {number}
|
|
830
|
+
* Gets the bottom y position of this display object.
|
|
831
|
+
* @returns {number} The bottom y position in pixels.
|
|
822
832
|
*/
|
|
823
833
|
get bottom() {
|
|
824
834
|
return this.y + this.height - this.offsetY;
|
|
825
835
|
}
|
|
826
836
|
|
|
827
837
|
/**
|
|
828
|
-
*
|
|
838
|
+
* Sets the bottom y position of this display object.
|
|
839
|
+
* @param {number} value - The new bottom y position in pixels.
|
|
829
840
|
*/
|
|
830
841
|
set bottom(value) {
|
|
831
842
|
this.y = value - this.height + this.offsetY;
|