@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
|
@@ -5,14 +5,14 @@ import { Image } from './image.js';
|
|
|
5
5
|
|
|
6
6
|
export class BitmapText extends DisplayObject {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {import('../core/game.js').Game} game -
|
|
10
|
-
* @param {number} x -
|
|
11
|
-
* @param {number} y -
|
|
12
|
-
* @param {string} font -
|
|
13
|
-
* @param {string} text -
|
|
14
|
-
* @param {number} size -
|
|
15
|
-
* @param {string} align -
|
|
8
|
+
* Creates a new BitmapText instance.
|
|
9
|
+
* @param {import('../core/game.js').Game} game - The game instance this bitmap text belongs to.
|
|
10
|
+
* @param {number} x - The x position of the bitmap text.
|
|
11
|
+
* @param {number} y - The y position of the bitmap text.
|
|
12
|
+
* @param {string} font - The key of the bitmap font to use.
|
|
13
|
+
* @param {string} text - The text to display.
|
|
14
|
+
* @param {number} size - The font size.
|
|
15
|
+
* @param {string} align - The text alignment (left, center, right).
|
|
16
16
|
*/
|
|
17
17
|
constructor(game, x = 0, y = 0, font = '', text = '', size = 32, align = 'left') {
|
|
18
18
|
super(game);
|
|
@@ -45,7 +45,7 @@ export class BitmapText extends DisplayObject {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Destroys this bitmap text and cleans up resources.
|
|
49
49
|
*/
|
|
50
50
|
destroy() {
|
|
51
51
|
this._prevAnchor = null;
|
|
@@ -56,7 +56,7 @@ export class BitmapText extends DisplayObject {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Called before the update cycle for this bitmap text.
|
|
60
60
|
*/
|
|
61
61
|
preUpdate() {
|
|
62
62
|
if (this.pendingDestroy) {
|
|
@@ -78,19 +78,19 @@ export class BitmapText extends DisplayObject {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param {string} text -
|
|
81
|
+
* Sets the text to display.
|
|
82
|
+
* @param {string} text - The new text to display.
|
|
83
83
|
*/
|
|
84
84
|
setText(text) {
|
|
85
85
|
this.text = text;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @param {object} data -
|
|
91
|
-
* @param {number} scale -
|
|
92
|
-
* @param {string} text -
|
|
93
|
-
* @returns {{width: number, text: string, end: boolean, chars: number[]}}
|
|
89
|
+
* Scans a line of text to calculate its width and other properties.
|
|
90
|
+
* @param {object} data - The font data for this bitmap text.
|
|
91
|
+
* @param {number} scale - The scaling factor to apply to the font size.
|
|
92
|
+
* @param {string} text - The text to scan.
|
|
93
|
+
* @returns {{width: number, text: string, end: boolean, chars: number[]}} An object containing the width, processed text, end status, and character positions.
|
|
94
94
|
*/
|
|
95
95
|
scanLine(data, scale, text) {
|
|
96
96
|
let x = 0;
|
|
@@ -154,10 +154,10 @@ export class BitmapText extends DisplayObject {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
* @param {string} text -
|
|
159
|
-
* @param {string} replace -
|
|
160
|
-
* @returns {string}
|
|
157
|
+
* Cleans the provided text by removing invalid characters and replacing them with a specified character.
|
|
158
|
+
* @param {string} text - The text to clean.
|
|
159
|
+
* @param {string} replace - The character to use for replacement of invalid characters (default: '').
|
|
160
|
+
* @returns {string} The cleaned text.
|
|
161
161
|
*/
|
|
162
162
|
cleanText(text, replace = '') {
|
|
163
163
|
const data = this._data.font;
|
|
@@ -182,7 +182,7 @@ export class BitmapText extends DisplayObject {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
185
|
+
* Updates the internal text rendering based on current properties and content.
|
|
186
186
|
*/
|
|
187
187
|
updateText() {
|
|
188
188
|
const data = this._data.font;
|
|
@@ -253,8 +253,8 @@ export class BitmapText extends DisplayObject {
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
/**
|
|
256
|
-
*
|
|
257
|
-
* @returns {number}
|
|
256
|
+
* Removes unused glyphs from the pool and returns the number removed.
|
|
257
|
+
* @returns {number} The number of glyphs that were removed from the pool.
|
|
258
258
|
*/
|
|
259
259
|
purgeGlyphs() {
|
|
260
260
|
const len = this._glyphs.length;
|
|
@@ -274,7 +274,7 @@ export class BitmapText extends DisplayObject {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* Updates the transform of this bitmap text, updating its text if needed.
|
|
278
278
|
*/
|
|
279
279
|
updateTransform() {
|
|
280
280
|
if (this.dirty || !this.anchor.equals(this._prevAnchor)) {
|
|
@@ -286,10 +286,10 @@ export class BitmapText extends DisplayObject {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @param {string} value -
|
|
291
|
-
* @param {number} position -
|
|
292
|
-
* @returns {BitmapText}
|
|
289
|
+
* Adds a color to a specific position in the text.
|
|
290
|
+
* @param {string} value - The color to apply (in hex format or CSS color name).
|
|
291
|
+
* @param {number} position - The character position to apply the color to.
|
|
292
|
+
* @returns {BitmapText} This bitmap text instance for chaining.
|
|
293
293
|
*/
|
|
294
294
|
addColor(value, position) {
|
|
295
295
|
const color = typeof value === 'string' ? Number.parseInt(value.replace('#', ''), 16) : value;
|
|
@@ -301,15 +301,16 @@ export class BitmapText extends DisplayObject {
|
|
|
301
301
|
}
|
|
302
302
|
|
|
303
303
|
/**
|
|
304
|
-
*
|
|
305
|
-
* @returns {string}
|
|
304
|
+
* Gets the text alignment property.
|
|
305
|
+
* @returns {string} The current text alignment (left, center, right).
|
|
306
306
|
*/
|
|
307
307
|
get align() {
|
|
308
308
|
return this._align;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
/**
|
|
312
|
-
*
|
|
312
|
+
* Sets the text alignment property.
|
|
313
|
+
* @param {string} value - The new text alignment (left, center, right).
|
|
313
314
|
*/
|
|
314
315
|
set align(value) {
|
|
315
316
|
if (value !== this._align && (value === 'left' || value === 'center' || value === 'right')) {
|
|
@@ -319,15 +320,16 @@ export class BitmapText extends DisplayObject {
|
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
/**
|
|
322
|
-
*
|
|
323
|
-
* @returns {number}
|
|
323
|
+
* Gets the tint color of this bitmap text.
|
|
324
|
+
* @returns {number} The current tint color in RGB format.
|
|
324
325
|
*/
|
|
325
326
|
get tint() {
|
|
326
327
|
return this._tint;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
/**
|
|
330
|
-
*
|
|
331
|
+
* Sets the tint color of this bitmap text.
|
|
332
|
+
* @param {number} value - The new tint color in RGB format.
|
|
331
333
|
*/
|
|
332
334
|
set tint(value) {
|
|
333
335
|
if (value !== this._tint) {
|
|
@@ -337,8 +339,8 @@ export class BitmapText extends DisplayObject {
|
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
/**
|
|
340
|
-
*
|
|
341
|
-
* @returns {string}
|
|
342
|
+
* Gets the fill color of this bitmap text as a hex string.
|
|
343
|
+
* @returns {string} The current fill color in hex format.
|
|
342
344
|
*/
|
|
343
345
|
get fill() {
|
|
344
346
|
if (typeof this.tint === 'number') {
|
|
@@ -352,22 +354,24 @@ export class BitmapText extends DisplayObject {
|
|
|
352
354
|
}
|
|
353
355
|
|
|
354
356
|
/**
|
|
355
|
-
*
|
|
357
|
+
* Sets the fill color of this bitmap text.
|
|
358
|
+
* @param {string} value - The new fill color in hex format or CSS color name.
|
|
356
359
|
*/
|
|
357
360
|
set fill(value) {
|
|
358
361
|
this.tint = typeof value === 'string' ? Number.parseInt(value.replace('#', ''), 16) : value;
|
|
359
362
|
}
|
|
360
363
|
|
|
361
364
|
/**
|
|
362
|
-
*
|
|
363
|
-
* @returns {string}
|
|
365
|
+
* Gets the font key used by this bitmap text.
|
|
366
|
+
* @returns {string} The current font key.
|
|
364
367
|
*/
|
|
365
368
|
get font() {
|
|
366
369
|
return this._font;
|
|
367
370
|
}
|
|
368
371
|
|
|
369
372
|
/**
|
|
370
|
-
*
|
|
373
|
+
* Sets the font key used by this bitmap text.
|
|
374
|
+
* @param {string} value - The new font key to use.
|
|
371
375
|
*/
|
|
372
376
|
set font(value) {
|
|
373
377
|
const trimmedValue = value.trim();
|
|
@@ -379,15 +383,16 @@ export class BitmapText extends DisplayObject {
|
|
|
379
383
|
}
|
|
380
384
|
|
|
381
385
|
/**
|
|
382
|
-
*
|
|
383
|
-
* @returns {number}
|
|
386
|
+
* Gets the font size of this bitmap text.
|
|
387
|
+
* @returns {number} The current font size.
|
|
384
388
|
*/
|
|
385
389
|
get fontSize() {
|
|
386
390
|
return this._fontSize;
|
|
387
391
|
}
|
|
388
392
|
|
|
389
393
|
/**
|
|
390
|
-
*
|
|
394
|
+
* Sets the font size of this bitmap text.
|
|
395
|
+
* @param {number} value - The new font size to use.
|
|
391
396
|
*/
|
|
392
397
|
set fontSize(value) {
|
|
393
398
|
value = Number.parseInt(value, 10);
|
|
@@ -398,16 +403,16 @@ export class BitmapText extends DisplayObject {
|
|
|
398
403
|
}
|
|
399
404
|
|
|
400
405
|
/**
|
|
401
|
-
*
|
|
402
|
-
* @returns {string}
|
|
406
|
+
* Gets the text content of this bitmap text.
|
|
407
|
+
* @returns {string} The current text content.
|
|
403
408
|
*/
|
|
404
409
|
get text() {
|
|
405
410
|
return this._text;
|
|
406
411
|
}
|
|
407
412
|
|
|
408
413
|
/**
|
|
409
|
-
*
|
|
410
|
-
* @param {string | number | boolean | Date} value -
|
|
414
|
+
* Sets the text content of this bitmap text.
|
|
415
|
+
* @param {string | number | boolean | Date} value - The new text content to set.
|
|
411
416
|
*/
|
|
412
417
|
set text(value) {
|
|
413
418
|
const typedValue = value.toString();
|
|
@@ -418,15 +423,16 @@ export class BitmapText extends DisplayObject {
|
|
|
418
423
|
}
|
|
419
424
|
|
|
420
425
|
/**
|
|
421
|
-
*
|
|
422
|
-
* @returns {number}
|
|
426
|
+
* Gets the maximum width of this bitmap text.
|
|
427
|
+
* @returns {number} The current maximum width.
|
|
423
428
|
*/
|
|
424
429
|
get maxWidth() {
|
|
425
430
|
return this._maxWidth;
|
|
426
431
|
}
|
|
427
432
|
|
|
428
433
|
/**
|
|
429
|
-
*
|
|
434
|
+
* Sets the maximum width of this bitmap text.
|
|
435
|
+
* @param {number} value - The new maximum width to set.
|
|
430
436
|
*/
|
|
431
437
|
set maxWidth(value) {
|
|
432
438
|
if (value !== this._maxWidth) {
|
|
@@ -436,15 +442,16 @@ export class BitmapText extends DisplayObject {
|
|
|
436
442
|
}
|
|
437
443
|
|
|
438
444
|
/**
|
|
439
|
-
*
|
|
440
|
-
* @returns {boolean}
|
|
445
|
+
* Gets whether smoothing is enabled for this bitmap text's font.
|
|
446
|
+
* @returns {boolean} True if smoothing is enabled, false otherwise.
|
|
441
447
|
*/
|
|
442
448
|
get smoothed() {
|
|
443
449
|
return !this._data.base.scaleMode;
|
|
444
450
|
}
|
|
445
451
|
|
|
446
452
|
/**
|
|
447
|
-
*
|
|
453
|
+
* Sets whether smoothing is enabled for this bitmap text's font.
|
|
454
|
+
* @param {boolean} value - Whether to enable smoothing (true) or not (false).
|
|
448
455
|
*/
|
|
449
456
|
set smoothed(value) {
|
|
450
457
|
if (value) {
|
|
@@ -11,18 +11,18 @@ const STATE_DISABLED = 'Disabled';
|
|
|
11
11
|
|
|
12
12
|
export class Button extends Image {
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {import('../core/game.js').Game} game -
|
|
16
|
-
* @param {number} x -
|
|
17
|
-
* @param {number} y -
|
|
18
|
-
* @param {string} key -
|
|
19
|
-
* @param {Function} callback -
|
|
20
|
-
* @param {object} callbackContext -
|
|
21
|
-
* @param {string} overFrame -
|
|
22
|
-
* @param {string} outFrame -
|
|
23
|
-
* @param {string} downFrame -
|
|
24
|
-
* @param {string} upFrame -
|
|
25
|
-
* @param {string} disabledFrame -
|
|
14
|
+
* Creates a new Button instance.
|
|
15
|
+
* @param {import('../core/game.js').Game} game - The game instance this button belongs to.
|
|
16
|
+
* @param {number} x - The x position of the button.
|
|
17
|
+
* @param {number} y - The y position of the button.
|
|
18
|
+
* @param {string} key - The texture key to use for the button.
|
|
19
|
+
* @param {Function} callback - The function to call when the button is clicked.
|
|
20
|
+
* @param {object} callbackContext - The context in which to call the callback function.
|
|
21
|
+
* @param {string} overFrame - The frame identifier to use when the mouse is over the button.
|
|
22
|
+
* @param {string} outFrame - The frame identifier to use when the mouse is outside the button.
|
|
23
|
+
* @param {string} downFrame - The frame identifier to use when the button is pressed.
|
|
24
|
+
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
25
|
+
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
26
26
|
*/
|
|
27
27
|
constructor(
|
|
28
28
|
game,
|
|
@@ -67,7 +67,7 @@ export class Button extends Image {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
*
|
|
70
|
+
* Destroys this button and cleans up resources.
|
|
71
71
|
*/
|
|
72
72
|
destroy() {
|
|
73
73
|
this._onOverFrame = null;
|
|
@@ -93,9 +93,9 @@ export class Button extends Image {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {boolean} isEnabled -
|
|
98
|
-
* @param {boolean} isImmediate -
|
|
96
|
+
* Sets whether this button is enabled or disabled.
|
|
97
|
+
* @param {boolean} isEnabled - Whether the button should be enabled (true) or disabled (false).
|
|
98
|
+
* @param {boolean} isImmediate - Whether to change the state immediately or with a delay (default: false).
|
|
99
99
|
*/
|
|
100
100
|
setEnabled(isEnabled, isImmediate = false) {
|
|
101
101
|
this.input.enabled = isEnabled;
|
|
@@ -109,24 +109,24 @@ export class Button extends Image {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* Clears all the frame settings for this button.
|
|
113
113
|
*/
|
|
114
114
|
clearFrames() {
|
|
115
115
|
this.setFrames(null, null, null, null, null);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
*
|
|
119
|
+
* Called when this button is removed from the world.
|
|
120
120
|
*/
|
|
121
121
|
removedFromWorld() {
|
|
122
122
|
this.inputEnabled = false;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
*
|
|
127
|
-
* @param {string} state -
|
|
128
|
-
* @param {string} frame -
|
|
129
|
-
* @param {boolean} switchImmediately -
|
|
126
|
+
* Sets a specific frame for a particular state of this button.
|
|
127
|
+
* @param {string} state - The state name (Over, Out, Down, Up, Disabled).
|
|
128
|
+
* @param {string} frame - The frame identifier to set for this state.
|
|
129
|
+
* @param {boolean} switchImmediately - Whether to switch to the new frame immediately (default: false).
|
|
130
130
|
*/
|
|
131
131
|
setStateFrame(state, frame, switchImmediately = false) {
|
|
132
132
|
const frameKey = `_on${state}Frame`;
|
|
@@ -141,9 +141,9 @@ export class Button extends Image {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @param {string} newState -
|
|
146
|
-
* @returns {boolean}
|
|
144
|
+
* Changes the frame of this button to match the specified state.
|
|
145
|
+
* @param {string} newState - The new state to change to (Over, Out, Down, Up, Disabled).
|
|
146
|
+
* @returns {boolean} True if the frame was changed, false otherwise.
|
|
147
147
|
*/
|
|
148
148
|
changeStateFrame(newState) {
|
|
149
149
|
if (this.freezeFrames) {
|
|
@@ -163,12 +163,12 @@ export class Button extends Image {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param {string} overFrame -
|
|
168
|
-
* @param {string} outFrame -
|
|
169
|
-
* @param {string} downFrame -
|
|
170
|
-
* @param {string} upFrame -
|
|
171
|
-
* @param {string} disabledFrame -
|
|
166
|
+
* Sets the frame identifiers for all states of this button.
|
|
167
|
+
* @param {string} overFrame - The frame identifier to use when the mouse is over the button.
|
|
168
|
+
* @param {string} outFrame - The frame identifier to use when the mouse is outside the button.
|
|
169
|
+
* @param {string} downFrame - The frame identifier to use when the button is pressed.
|
|
170
|
+
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
171
|
+
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
172
172
|
*/
|
|
173
173
|
setFrames(overFrame, outFrame, downFrame, upFrame, disabledFrame = null) {
|
|
174
174
|
this.setStateFrame(STATE_OVER, overFrame, this.input.pointerOver());
|
|
@@ -181,9 +181,9 @@ export class Button extends Image {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
|
-
*
|
|
185
|
-
* @param {object} sprite -
|
|
186
|
-
* @param {object} pointer -
|
|
184
|
+
* Handles the input over event for this button.
|
|
185
|
+
* @param {object} sprite - The sprite that triggered the event.
|
|
186
|
+
* @param {object} pointer - The pointer that triggered the event.
|
|
187
187
|
*/
|
|
188
188
|
onInputOverHandler(sprite, pointer) {
|
|
189
189
|
if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
|
|
@@ -200,9 +200,9 @@ export class Button extends Image {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
-
*
|
|
204
|
-
* @param {object} sprite -
|
|
205
|
-
* @param {object} pointer -
|
|
203
|
+
* Handles the input out event for this button.
|
|
204
|
+
* @param {object} sprite - The sprite that triggered the event.
|
|
205
|
+
* @param {object} pointer - The pointer that triggered the event.
|
|
206
206
|
*/
|
|
207
207
|
onInputOutHandler(sprite, pointer) {
|
|
208
208
|
this.changeStateFrame(STATE_OUT);
|
|
@@ -212,9 +212,9 @@ export class Button extends Image {
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
216
|
-
* @param {object} sprite -
|
|
217
|
-
* @param {object} pointer -
|
|
215
|
+
* Handles the input down event for this button.
|
|
216
|
+
* @param {object} sprite - The sprite that triggered the event.
|
|
217
|
+
* @param {object} pointer - The pointer that triggered the event.
|
|
218
218
|
*/
|
|
219
219
|
onInputDownHandler(sprite, pointer) {
|
|
220
220
|
this.changeStateFrame(STATE_DOWN);
|
|
@@ -224,10 +224,10 @@ export class Button extends Image {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
*
|
|
228
|
-
* @param {object} sprite -
|
|
229
|
-
* @param {object} pointer -
|
|
230
|
-
* @param {boolean} isOver -
|
|
227
|
+
* Handles the input up event for this button.
|
|
228
|
+
* @param {object} sprite - The sprite that triggered the event.
|
|
229
|
+
* @param {object} pointer - The pointer that triggered the event.
|
|
230
|
+
* @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
|
|
231
231
|
*/
|
|
232
232
|
onInputUpHandler(sprite, pointer, isOver) {
|
|
233
233
|
if (this.onInputUp) {
|
|
@@ -252,15 +252,16 @@ export class Button extends Image {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
|
-
*
|
|
256
|
-
* @returns {boolean}
|
|
255
|
+
* Gets whether input is currently enabled for this button.
|
|
256
|
+
* @returns {boolean} True if input is enabled, false otherwise.
|
|
257
257
|
*/
|
|
258
258
|
get inputEnabled() {
|
|
259
259
|
return this.input && this.input.enabled;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
|
-
*
|
|
263
|
+
* Sets whether input is currently enabled for this button.
|
|
264
|
+
* @param {boolean} value - Whether to enable (true) or disable (false) input.
|
|
264
265
|
*/
|
|
265
266
|
set inputEnabled(value) {
|
|
266
267
|
if (value) {
|
|
@@ -2,9 +2,9 @@ import { create, removeByCanvas } from './pool.js';
|
|
|
2
2
|
|
|
3
3
|
export class CanvasBuffer {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {number} width -
|
|
7
|
-
* @param {number} height -
|
|
5
|
+
* Creates a new CanvasBuffer instance.
|
|
6
|
+
* @param {number} width - The width of the canvas buffer.
|
|
7
|
+
* @param {number} height - The height of the canvas buffer.
|
|
8
8
|
*/
|
|
9
9
|
constructor(width, height) {
|
|
10
10
|
this.width = width;
|
|
@@ -16,7 +16,7 @@ export class CanvasBuffer {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Clears the canvas buffer.
|
|
20
20
|
*/
|
|
21
21
|
clear() {
|
|
22
22
|
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
|
@@ -24,9 +24,9 @@ export class CanvasBuffer {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {number} width -
|
|
29
|
-
* @param {number} height -
|
|
27
|
+
* Resizes the canvas buffer.
|
|
28
|
+
* @param {number} width - The new width of the canvas buffer.
|
|
29
|
+
* @param {number} height - The new height of the canvas buffer.
|
|
30
30
|
*/
|
|
31
31
|
resize(width, height) {
|
|
32
32
|
this.width = width;
|
|
@@ -36,7 +36,7 @@ export class CanvasBuffer {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Destroys the canvas buffer and cleans up resources.
|
|
40
40
|
*/
|
|
41
41
|
destroy() {
|
|
42
42
|
try {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_POLYGON, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../../core/const.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
4
|
+
* Renders a graphics object to canvas.
|
|
5
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
6
6
|
*/
|
|
7
7
|
export const updateGraphicsTint = (graphics) => {
|
|
8
8
|
if (graphics.tint === 0xffffff) {
|
|
@@ -27,9 +27,9 @@ export const updateGraphicsTint = (graphics) => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
32
|
-
* @param {object} context -
|
|
30
|
+
* Renders a graphics object to canvas.
|
|
31
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
32
|
+
* @param {object} context - The canvas rendering context.
|
|
33
33
|
*/
|
|
34
34
|
export const renderGraphics = (graphics, context) => {
|
|
35
35
|
const worldAlpha = graphics.worldAlpha;
|
|
@@ -156,9 +156,9 @@ export const renderGraphics = (graphics, context) => {
|
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* @param {import('../graphics.js').Graphics} graphics -
|
|
161
|
-
* @param {object} context -
|
|
159
|
+
* Renders a graphics object to canvas.
|
|
160
|
+
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
161
|
+
* @param {object} context - The canvas rendering context.
|
|
162
162
|
*/
|
|
163
163
|
export const renderGraphicsMask = (graphics, context) => {
|
|
164
164
|
const len = graphics.graphicsData.length;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { renderGraphicsMask } from './graphics.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {object} maskData -
|
|
6
|
-
* @param {object} renderSession -
|
|
4
|
+
* Pushes a mask onto the rendering stack.
|
|
5
|
+
* @param {object} maskData - The mask data to apply.
|
|
6
|
+
* @param {object} renderSession - The rendering session object.
|
|
7
7
|
*/
|
|
8
8
|
export const pushMask = (maskData, renderSession) => {
|
|
9
9
|
const context = renderSession.context;
|
|
@@ -25,8 +25,8 @@ export const pushMask = (maskData, renderSession) => {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param {object} renderSession -
|
|
28
|
+
* Pops a mask from the rendering stack.
|
|
29
|
+
* @param {object} renderSession - The rendering session object.
|
|
30
30
|
*/
|
|
31
31
|
export const popMask = (renderSession) => {
|
|
32
32
|
renderSession.context.restore();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @returns {{canvas: HTMLCanvasElement, parent: object}[]}
|
|
2
|
+
* Gets the canvas pool array.
|
|
3
|
+
* @returns {{canvas: HTMLCanvasElement, parent: object}[]} The canvas pool array.
|
|
4
4
|
*/
|
|
5
5
|
export const getPool = () => {
|
|
6
6
|
if (!window.PhaserRegistry) {
|
|
@@ -13,8 +13,8 @@ export const getPool = () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @returns {number}
|
|
16
|
+
* Gets the current size of the canvas pool.
|
|
17
|
+
* @returns {number} The current size of the canvas pool.
|
|
18
18
|
*/
|
|
19
19
|
export const getFirst = () => {
|
|
20
20
|
const pool = getPool();
|
|
@@ -27,8 +27,8 @@ export const getFirst = () => {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {object} parent -
|
|
30
|
+
* Adds a canvas to the pool with the specified parent.
|
|
31
|
+
* @param {object} parent - The parent object for the canvas.
|
|
32
32
|
*/
|
|
33
33
|
export const remove = (parent) => {
|
|
34
34
|
const pool = getPool();
|
|
@@ -42,8 +42,8 @@ export const remove = (parent) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param {HTMLCanvasElement} canvas -
|
|
45
|
+
* Removes a canvas from the pool.
|
|
46
|
+
* @param {HTMLCanvasElement} canvas - The canvas to remove from the pool.
|
|
47
47
|
*/
|
|
48
48
|
export const removeByCanvas = (canvas) => {
|
|
49
49
|
const pool = getPool();
|
|
@@ -57,8 +57,8 @@ export const removeByCanvas = (canvas) => {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @returns {number}
|
|
60
|
+
* Gets the total count of canvases in the pool.
|
|
61
|
+
* @returns {number} The total count of canvases in the pool.
|
|
62
62
|
*/
|
|
63
63
|
export const getTotal = () => {
|
|
64
64
|
const pool = getPool();
|
|
@@ -72,8 +72,8 @@ export const getTotal = () => {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @returns {number}
|
|
75
|
+
* Gets the number of free canvases in the pool.
|
|
76
|
+
* @returns {number} The number of free canvases in the pool.
|
|
77
77
|
*/
|
|
78
78
|
export const getFree = () => {
|
|
79
79
|
const pool = getPool();
|
|
@@ -87,12 +87,12 @@ export const getFree = () => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param {object} parent -
|
|
92
|
-
* @param {number} [width] -
|
|
93
|
-
* @param {number} [height] -
|
|
94
|
-
* @param {boolean} skipPool -
|
|
95
|
-
* @returns {HTMLCanvasElement}
|
|
90
|
+
* Gets a canvas from the pool or creates a new one.
|
|
91
|
+
* @param {object} parent - The parent object for the canvas.
|
|
92
|
+
* @param {number} [width] - Optional width of the canvas.
|
|
93
|
+
* @param {number} [height] - Optional height of the canvas.
|
|
94
|
+
* @param {boolean} skipPool - True to skip using the pool and create a new canvas.
|
|
95
|
+
* @returns {HTMLCanvasElement} The canvas from the pool or a newly created one.
|
|
96
96
|
*/
|
|
97
97
|
export const create = (parent, width, height, skipPool = false) => {
|
|
98
98
|
if (parent === undefined) {
|