@vpmedia/phaser 1.95.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 +29 -0
- package/package.json +9 -9
- 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 +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 +30 -30
- package/src/phaser/core/timer.js +64 -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/ellipse.js +28 -28
- package/src/phaser/geom/line.js +93 -93
- package/src/phaser/geom/matrix.js +54 -54
- package/src/phaser/geom/point.js +96 -96
- package/src/phaser/geom/polygon.js +22 -22
- package/src/phaser/geom/rectangle.js +132 -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 +61 -56
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +55 -55
- package/types/phaser/core/cache.d.ts +154 -154
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +43 -43
- package/types/phaser/core/event_manager.d.ts +63 -63
- package/types/phaser/core/factory.d.ts +47 -47
- package/types/phaser/core/frame.d.ts +30 -30
- package/types/phaser/core/frame_data.d.ts +28 -27
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +52 -19
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +170 -170
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +1 -1
- package/types/phaser/core/scene.d.ts +15 -9
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +51 -43
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +54 -51
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +54 -54
- package/types/phaser/core/sound_manager.d.ts +49 -49
- package/types/phaser/core/stage.d.ts +10 -10
- package/types/phaser/core/time.d.ts +30 -30
- package/types/phaser/core/timer.d.ts +64 -64
- package/types/phaser/core/timer_event.d.ts +9 -9
- package/types/phaser/core/tween.d.ts +90 -90
- package/types/phaser/core/tween_data.d.ts +30 -30
- package/types/phaser/core/tween_manager.d.ts +29 -24
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +4 -3
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +59 -52
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +47 -46
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +8 -8
- package/types/phaser/display/canvas/renderer.d.ts +16 -16
- package/types/phaser/display/display_object.d.ts +119 -108
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +101 -101
- package/types/phaser/display/graphics_data.d.ts +10 -10
- package/types/phaser/display/group.d.ts +47 -47
- package/types/phaser/display/image.d.ts +42 -40
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +207 -184
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
- package/types/phaser/display/webgl/base_texture.d.ts +9 -9
- package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
- package/types/phaser/display/webgl/earcut.d.ts +95 -95
- package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
- package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
- package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
- package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
- package/types/phaser/display/webgl/render_texture.d.ts +16 -16
- package/types/phaser/display/webgl/renderer.d.ts +20 -20
- package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
- package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
- package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
- package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
- package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
- package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
- package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
- package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
- package/types/phaser/display/webgl/texture.d.ts +12 -12
- package/types/phaser/geom/circle.d.ts +69 -69
- package/types/phaser/geom/ellipse.d.ts +28 -28
- package/types/phaser/geom/line.d.ts +93 -93
- package/types/phaser/geom/matrix.d.ts +54 -54
- package/types/phaser/geom/point.d.ts +96 -96
- package/types/phaser/geom/polygon.d.ts +22 -22
- package/types/phaser/geom/rectangle.d.ts +132 -132
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
- package/pnpm-workspace.yaml +0 -4
package/src/phaser/core/cache.js
CHANGED
|
@@ -19,8 +19,8 @@ export const RENDER_TEXTURE = 9;
|
|
|
19
19
|
|
|
20
20
|
export class Cache {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {import('./game.js').Game} game -
|
|
22
|
+
* Creates a new Cache instance.
|
|
23
|
+
* @param {import('./game.js').Game} game - The game instance.
|
|
24
24
|
*/
|
|
25
25
|
constructor(game) {
|
|
26
26
|
this.game = game;
|
|
@@ -57,7 +57,7 @@ export class Cache {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Adds the default image to the cache.
|
|
61
61
|
*/
|
|
62
62
|
addDefaultImage() {
|
|
63
63
|
const img = new Image();
|
|
@@ -69,7 +69,7 @@ export class Cache {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Adds the missing image to the cache.
|
|
73
73
|
*/
|
|
74
74
|
addMissingImage() {
|
|
75
75
|
const img = new Image();
|
|
@@ -80,11 +80,11 @@ export class Cache {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param {string} key -
|
|
85
|
-
* @param {string} url -
|
|
86
|
-
* @param {HTMLImageElement} data -
|
|
87
|
-
* @returns {object}
|
|
83
|
+
* Adds an image to the cache.
|
|
84
|
+
* @param {string} key - The unique key for this cache entry.
|
|
85
|
+
* @param {string} url - The URL the image was loaded from.
|
|
86
|
+
* @param {HTMLImageElement} data - The image data to cache.
|
|
87
|
+
* @returns {object} The cached image object.
|
|
88
88
|
*/
|
|
89
89
|
addImage(key, url, data) {
|
|
90
90
|
if (this.checkImageKey(key)) {
|
|
@@ -108,11 +108,11 @@ export class Cache {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @param {string} key -
|
|
113
|
-
* @param {string} url -
|
|
114
|
-
* @param {HTMLCanvasElement} data -
|
|
115
|
-
* @param {object} atlasData -
|
|
111
|
+
* Adds a texture atlas to the cache.
|
|
112
|
+
* @param {string} key - The unique key for this cache entry.
|
|
113
|
+
* @param {string} url - The URL the atlas was loaded from.
|
|
114
|
+
* @param {HTMLCanvasElement} data - The canvas data for the atlas.
|
|
115
|
+
* @param {object} atlasData - The atlas data to cache.
|
|
116
116
|
*/
|
|
117
117
|
addTextureAtlas(key, url, data, atlasData) {
|
|
118
118
|
const obj = {
|
|
@@ -127,10 +127,10 @@ export class Cache {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @param {string} key -
|
|
132
|
-
* @param {string} url -
|
|
133
|
-
* @param {object} data -
|
|
130
|
+
* Adds sound data to the cache.
|
|
131
|
+
* @param {string} key - The unique key for this cache entry.
|
|
132
|
+
* @param {string} url - The URL the sound was loaded from.
|
|
133
|
+
* @param {object} data - The sound data to cache.
|
|
134
134
|
*/
|
|
135
135
|
addSound(key, url, data) {
|
|
136
136
|
this._cache.sound[key] = {
|
|
@@ -143,10 +143,10 @@ export class Cache {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @param {string} key -
|
|
148
|
-
* @param {string} url -
|
|
149
|
-
* @param {string} data -
|
|
146
|
+
* Adds text data to the cache.
|
|
147
|
+
* @param {string} key - The unique key for this cache entry.
|
|
148
|
+
* @param {string} url - The URL the text was loaded from.
|
|
149
|
+
* @param {string} data - The text data to cache.
|
|
150
150
|
*/
|
|
151
151
|
addText(key, url, data) {
|
|
152
152
|
this._cache.text[key] = { url, data };
|
|
@@ -154,14 +154,14 @@ export class Cache {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
158
|
-
* @param {string} key -
|
|
159
|
-
* @param {string} url -
|
|
160
|
-
* @param {HTMLCanvasElement} data -
|
|
161
|
-
* @param {object} atlasData -
|
|
162
|
-
* @param {string} atlasType -
|
|
163
|
-
* @param {number} xSpacing -
|
|
164
|
-
* @param {number} ySpacing -
|
|
157
|
+
* Adds a bitmap font to the cache.
|
|
158
|
+
* @param {string} key - The unique key for this cache entry.
|
|
159
|
+
* @param {string} url - The URL the bitmap font was loaded from.
|
|
160
|
+
* @param {HTMLCanvasElement} data - The canvas data for the font.
|
|
161
|
+
* @param {object} atlasData - The bitmap font atlas data to cache.
|
|
162
|
+
* @param {string} atlasType - The type of the atlas data ('json' or 'xml').
|
|
163
|
+
* @param {number} xSpacing - Horizontal spacing between characters.
|
|
164
|
+
* @param {number} ySpacing - Vertical spacing between characters.
|
|
165
165
|
*/
|
|
166
166
|
addBitmapFont(key, url, data, atlasData, atlasType, xSpacing = 0, ySpacing = 0) {
|
|
167
167
|
const obj = {
|
|
@@ -180,10 +180,10 @@ export class Cache {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
*
|
|
184
|
-
* @param {string} key -
|
|
185
|
-
* @param {string} url -
|
|
186
|
-
* @param {object} data -
|
|
183
|
+
* Adds JSON data to the cache.
|
|
184
|
+
* @param {string} key - The unique key for this cache entry.
|
|
185
|
+
* @param {string} url - The URL the JSON was loaded from.
|
|
186
|
+
* @param {object} data - The JSON data to cache.
|
|
187
187
|
*/
|
|
188
188
|
addJSON(key, url, data) {
|
|
189
189
|
this._cache.json[key] = { url, data };
|
|
@@ -191,10 +191,10 @@ export class Cache {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
195
|
-
* @param {string} key -
|
|
196
|
-
* @param {string} url -
|
|
197
|
-
* @param {XMLDocument} data -
|
|
194
|
+
* Adds XML data to the cache.
|
|
195
|
+
* @param {string} key - The unique key for this cache entry.
|
|
196
|
+
* @param {string} url - The URL the XML was loaded from.
|
|
197
|
+
* @param {XMLDocument} data - The XML data to cache.
|
|
198
198
|
*/
|
|
199
199
|
addXML(key, url, data) {
|
|
200
200
|
this._cache.xml[key] = { url, data };
|
|
@@ -204,10 +204,10 @@ export class Cache {
|
|
|
204
204
|
// SOUND
|
|
205
205
|
|
|
206
206
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @param {string} key -
|
|
209
|
-
* @param {string} property -
|
|
210
|
-
* @param {any} value -
|
|
207
|
+
* Updates a sound property in the cache.
|
|
208
|
+
* @param {string} key - The unique key for the cached sound.
|
|
209
|
+
* @param {string} property - The property to update.
|
|
210
|
+
* @param {any} value - The new value for the property.
|
|
211
211
|
*/
|
|
212
212
|
updateSound(key, property, value) {
|
|
213
213
|
const sound = this.getSound(key);
|
|
@@ -217,9 +217,9 @@ export class Cache {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
|
-
*
|
|
221
|
-
* @param {string} key -
|
|
222
|
-
* @param {AudioBuffer} data -
|
|
220
|
+
* Marks a sound as decoded in the cache.
|
|
221
|
+
* @param {string} key - The unique key for the cached sound.
|
|
222
|
+
* @param {AudioBuffer} data - The decoded audio buffer.
|
|
223
223
|
*/
|
|
224
224
|
decodedSound(key, data) {
|
|
225
225
|
const sound = this.getSound(key);
|
|
@@ -229,9 +229,9 @@ export class Cache {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
233
|
-
* @param {string} key -
|
|
234
|
-
* @returns {boolean}
|
|
232
|
+
* Checks if a sound has been decoded in the cache.
|
|
233
|
+
* @param {string} key - The unique key for the cached sound.
|
|
234
|
+
* @returns {boolean} True if the sound is decoded, false otherwise.
|
|
235
235
|
*/
|
|
236
236
|
isSoundDecoded(key) {
|
|
237
237
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
@@ -242,9 +242,9 @@ export class Cache {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @param {string} key -
|
|
247
|
-
* @returns {boolean}
|
|
245
|
+
* Checks if a sound is ready to play (decoded and not locked).
|
|
246
|
+
* @param {string} key - The unique key for the cached sound.
|
|
247
|
+
* @returns {boolean} True if the sound is ready, false otherwise.
|
|
248
248
|
*/
|
|
249
249
|
isSoundReady(key) {
|
|
250
250
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
@@ -257,10 +257,10 @@ export class Cache {
|
|
|
257
257
|
// CHECK
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
|
-
*
|
|
261
|
-
* @param {number} cache -
|
|
262
|
-
* @param {string} key -
|
|
263
|
-
* @returns {boolean}
|
|
260
|
+
* Checks if a cache entry exists.
|
|
261
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
262
|
+
* @param {string} key - The unique key for the cache entry.
|
|
263
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
264
264
|
*/
|
|
265
265
|
checkKey(cache, key) {
|
|
266
266
|
if (this._cacheMap[cache][key]) {
|
|
@@ -270,9 +270,9 @@ export class Cache {
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
274
|
-
* @param {string} url -
|
|
275
|
-
* @returns {boolean}
|
|
273
|
+
* Checks if a URL has been resolved and cached.
|
|
274
|
+
* @param {string} url - The URL to check.
|
|
275
|
+
* @returns {boolean} True if the URL has been resolved and cached, false otherwise.
|
|
276
276
|
*/
|
|
277
277
|
checkURL(url) {
|
|
278
278
|
if (this._urlMap[this._resolveURL(url)]) {
|
|
@@ -282,81 +282,81 @@ export class Cache {
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
|
-
*
|
|
286
|
-
* @param {string} key -
|
|
287
|
-
* @returns {boolean}
|
|
285
|
+
* Checks if a canvas cache entry exists.
|
|
286
|
+
* @param {string} key - The unique key for the cache entry.
|
|
287
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
288
288
|
*/
|
|
289
289
|
checkCanvasKey(key) {
|
|
290
290
|
return this.checkKey(CANVAS, key);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
|
-
*
|
|
295
|
-
* @param {string} key -
|
|
296
|
-
* @returns {boolean}
|
|
294
|
+
* Checks if an image cache entry exists.
|
|
295
|
+
* @param {string} key - The unique key for the cache entry.
|
|
296
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
297
297
|
*/
|
|
298
298
|
checkImageKey(key) {
|
|
299
299
|
return this.checkKey(IMAGE, key);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
304
|
-
* @param {string} key -
|
|
305
|
-
* @returns {boolean}
|
|
303
|
+
* Checks if a texture cache entry exists.
|
|
304
|
+
* @param {string} key - The unique key for the cache entry.
|
|
305
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
306
306
|
*/
|
|
307
307
|
checkTextureKey(key) {
|
|
308
308
|
return this.checkKey(TEXTURE, key);
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
/**
|
|
312
|
-
*
|
|
313
|
-
* @param {string} key -
|
|
314
|
-
* @returns {boolean}
|
|
312
|
+
* Checks if a sound cache entry exists.
|
|
313
|
+
* @param {string} key - The unique key for the cache entry.
|
|
314
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
315
315
|
*/
|
|
316
316
|
checkSoundKey(key) {
|
|
317
317
|
return this.checkKey(SOUND, key);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
/**
|
|
321
|
-
*
|
|
322
|
-
* @param {string} key -
|
|
323
|
-
* @returns {boolean}
|
|
321
|
+
* Checks if a text cache entry exists.
|
|
322
|
+
* @param {string} key - The unique key for the cache entry.
|
|
323
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
324
324
|
*/
|
|
325
325
|
checkTextKey(key) {
|
|
326
326
|
return this.checkKey(TEXT, key);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
/**
|
|
330
|
-
*
|
|
331
|
-
* @param {string} key -
|
|
332
|
-
* @returns {boolean}
|
|
330
|
+
* Checks if a bitmap data cache entry exists.
|
|
331
|
+
* @param {string} key - The unique key for the cache entry.
|
|
332
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
333
333
|
*/
|
|
334
334
|
checkBitmapDataKey(key) {
|
|
335
335
|
return this.checkKey(BITMAPDATA, key);
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
/**
|
|
339
|
-
*
|
|
340
|
-
* @param {string} key -
|
|
341
|
-
* @returns {boolean}
|
|
339
|
+
* Checks if a bitmap font cache entry exists.
|
|
340
|
+
* @param {string} key - The unique key for the cache entry.
|
|
341
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
342
342
|
*/
|
|
343
343
|
checkBitmapFontKey(key) {
|
|
344
344
|
return this.checkKey(BITMAPFONT, key);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
/**
|
|
348
|
-
*
|
|
349
|
-
* @param {string} key -
|
|
350
|
-
* @returns {boolean}
|
|
348
|
+
* Checks if a JSON cache entry exists.
|
|
349
|
+
* @param {string} key - The unique key for the cache entry.
|
|
350
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
351
351
|
*/
|
|
352
352
|
checkJSONKey(key) {
|
|
353
353
|
return this.checkKey(JSONDATA, key);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
358
|
-
* @param {string} key -
|
|
359
|
-
* @returns {boolean}
|
|
357
|
+
* Checks if an XML cache entry exists.
|
|
358
|
+
* @param {string} key - The unique key for the cache entry.
|
|
359
|
+
* @returns {boolean} True if the entry exists, false otherwise.
|
|
360
360
|
*/
|
|
361
361
|
checkXMLKey(key) {
|
|
362
362
|
return this.checkKey(XML, key);
|
|
@@ -494,30 +494,30 @@ export class Cache {
|
|
|
494
494
|
// FRAME
|
|
495
495
|
|
|
496
496
|
/**
|
|
497
|
-
*
|
|
498
|
-
* @param {string} key -
|
|
499
|
-
* @param {number} cache -
|
|
500
|
-
* @returns {BaseTexture}
|
|
497
|
+
* Gets the base texture of a cache entry.
|
|
498
|
+
* @param {string} key - The unique key for the cache entry.
|
|
499
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
500
|
+
* @returns {BaseTexture} The base texture.
|
|
501
501
|
*/
|
|
502
502
|
getBaseTexture(key, cache = IMAGE) {
|
|
503
503
|
return this.getItem(key, cache, 'getBaseTexture', 'base');
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
/**
|
|
507
|
-
*
|
|
508
|
-
* @param {string} key -
|
|
509
|
-
* @param {number} cache -
|
|
510
|
-
* @returns {Frame}
|
|
507
|
+
* Gets a frame from the cache.
|
|
508
|
+
* @param {string} key - The unique key for the cache entry.
|
|
509
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
510
|
+
* @returns {Frame} The frame.
|
|
511
511
|
*/
|
|
512
512
|
getFrame(key, cache = IMAGE) {
|
|
513
513
|
return this.getItem(key, cache, 'getFrame', 'frame');
|
|
514
514
|
}
|
|
515
515
|
|
|
516
516
|
/**
|
|
517
|
-
*
|
|
518
|
-
* @param {string} key -
|
|
519
|
-
* @param {number} cache -
|
|
520
|
-
* @returns {number}
|
|
517
|
+
* Gets the frame count of a cache entry.
|
|
518
|
+
* @param {string} key - The unique key for the cache entry.
|
|
519
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
520
|
+
* @returns {number} The number of frames.
|
|
521
521
|
*/
|
|
522
522
|
getFrameCount(key, cache = IMAGE) {
|
|
523
523
|
const data = this.getFrameData(key, cache);
|
|
@@ -528,30 +528,30 @@ export class Cache {
|
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
/**
|
|
531
|
-
*
|
|
532
|
-
* @param {string} key -
|
|
533
|
-
* @param {number} cache -
|
|
534
|
-
* @returns {FrameData}
|
|
531
|
+
* Gets the frame data of a cache entry.
|
|
532
|
+
* @param {string} key - The unique key for the cache entry.
|
|
533
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
534
|
+
* @returns {FrameData} The frame data.
|
|
535
535
|
*/
|
|
536
536
|
getFrameData(key, cache = IMAGE) {
|
|
537
537
|
return this.getItem(key, cache, 'getFrameData', 'frameData');
|
|
538
538
|
}
|
|
539
539
|
|
|
540
540
|
/**
|
|
541
|
-
*
|
|
542
|
-
* @param {string} key -
|
|
543
|
-
* @param {number} cache -
|
|
544
|
-
* @returns {boolean}
|
|
541
|
+
* Checks if a cache entry has frame data.
|
|
542
|
+
* @param {string} key - The unique key for the cache entry.
|
|
543
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
544
|
+
* @returns {boolean} True if the entry has frame data, false otherwise.
|
|
545
545
|
*/
|
|
546
546
|
hasFrameData(key, cache = IMAGE) {
|
|
547
547
|
return this.getItem(key, cache, '', 'frameData') !== null;
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
/**
|
|
551
|
-
*
|
|
552
|
-
* @param {string} key -
|
|
553
|
-
* @param {FrameData} frameData -
|
|
554
|
-
* @param {number} cache -
|
|
551
|
+
* Updates the frame data of a cache entry.
|
|
552
|
+
* @param {string} key - The unique key for the cache entry.
|
|
553
|
+
* @param {FrameData} frameData - The new frame data.
|
|
554
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
555
555
|
*/
|
|
556
556
|
updateFrameData(key, frameData, cache = IMAGE) {
|
|
557
557
|
if (this._cacheMap[cache][key]) {
|
|
@@ -560,11 +560,11 @@ export class Cache {
|
|
|
560
560
|
}
|
|
561
561
|
|
|
562
562
|
/**
|
|
563
|
-
*
|
|
564
|
-
* @param {string} key -
|
|
565
|
-
* @param {number} index -
|
|
566
|
-
* @param {number} cache -
|
|
567
|
-
* @returns {Frame}
|
|
563
|
+
* Gets a frame by index from the cache.
|
|
564
|
+
* @param {string} key - The unique key for the cache entry.
|
|
565
|
+
* @param {number} index - The index of the frame to get.
|
|
566
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
567
|
+
* @returns {Frame} The frame at the specified index.
|
|
568
568
|
*/
|
|
569
569
|
getFrameByIndex(key, index, cache = IMAGE) {
|
|
570
570
|
const data = this.getFrameData(key, cache);
|
|
@@ -575,11 +575,11 @@ export class Cache {
|
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
/**
|
|
578
|
-
*
|
|
579
|
-
* @param {string} key -
|
|
580
|
-
* @param {string} name -
|
|
581
|
-
* @param {number} cache -
|
|
582
|
-
* @returns {Frame}
|
|
578
|
+
* Gets a frame by name from the cache.
|
|
579
|
+
* @param {string} key - The unique key for the cache entry.
|
|
580
|
+
* @param {string} name - The name of the frame to get.
|
|
581
|
+
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
582
|
+
* @returns {Frame} The frame with the specified name.
|
|
583
583
|
*/
|
|
584
584
|
getFrameByName(key, name, cache = IMAGE) {
|
|
585
585
|
const data = this.getFrameData(key, cache);
|
|
@@ -590,9 +590,9 @@ export class Cache {
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
|
-
*
|
|
594
|
-
* @param {string} url -
|
|
595
|
-
* @returns {string}
|
|
593
|
+
* Gets the resolved URL from cache.
|
|
594
|
+
* @param {string} url - The original URL to resolve.
|
|
595
|
+
* @returns {string} The resolved URL or null if not found.
|
|
596
596
|
*/
|
|
597
597
|
getURL(url) {
|
|
598
598
|
const resolvedURL = this._resolveURL(url);
|
|
@@ -604,9 +604,9 @@ export class Cache {
|
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
/**
|
|
607
|
-
*
|
|
608
|
-
* @param {object} cache -
|
|
609
|
-
* @returns {string[]}
|
|
607
|
+
* Gets all keys from a cache type.
|
|
608
|
+
* @param {object} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
609
|
+
* @returns {string[]} An array of cache keys.
|
|
610
610
|
*/
|
|
611
611
|
getKeys(cache = IMAGE) {
|
|
612
612
|
const result = [];
|
|
@@ -625,17 +625,17 @@ export class Cache {
|
|
|
625
625
|
// REMOVE
|
|
626
626
|
|
|
627
627
|
/**
|
|
628
|
-
*
|
|
629
|
-
* @param {string} key -
|
|
628
|
+
* Removes a canvas cache entry.
|
|
629
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
630
630
|
*/
|
|
631
631
|
removeCanvas(key) {
|
|
632
632
|
delete this._cache.canvas[key];
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
/**
|
|
636
|
-
*
|
|
637
|
-
* @param {string} key -
|
|
638
|
-
* @param {boolean} destroyBaseTexture -
|
|
636
|
+
* Removes an image cache entry.
|
|
637
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
638
|
+
* @param {boolean} destroyBaseTexture - Whether to destroy the base texture (default: true).
|
|
639
639
|
*/
|
|
640
640
|
removeImage(key, destroyBaseTexture = true) {
|
|
641
641
|
const img = this.getImage(key, true);
|
|
@@ -646,79 +646,79 @@ export class Cache {
|
|
|
646
646
|
}
|
|
647
647
|
|
|
648
648
|
/**
|
|
649
|
-
*
|
|
650
|
-
* @param {string} key -
|
|
649
|
+
* Removes a sound cache entry.
|
|
650
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
651
651
|
*/
|
|
652
652
|
removeSound(key) {
|
|
653
653
|
delete this._cache.sound[key];
|
|
654
654
|
}
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
|
-
*
|
|
658
|
-
* @param {string} key -
|
|
657
|
+
* Removes a text cache entry.
|
|
658
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
659
659
|
*/
|
|
660
660
|
removeText(key) {
|
|
661
661
|
delete this._cache.text[key];
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
/**
|
|
665
|
-
*
|
|
666
|
-
* @param {string} key -
|
|
665
|
+
* Removes a bitmap data cache entry.
|
|
666
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
667
667
|
*/
|
|
668
668
|
removeBitmapData(key) {
|
|
669
669
|
delete this._cache.bitmapData[key];
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
/**
|
|
673
|
-
*
|
|
674
|
-
* @param {string} key -
|
|
673
|
+
* Removes a bitmap font cache entry.
|
|
674
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
675
675
|
*/
|
|
676
676
|
removeBitmapFont(key) {
|
|
677
677
|
delete this._cache.bitmapFont[key];
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
/**
|
|
681
|
-
*
|
|
682
|
-
* @param {string} key -
|
|
681
|
+
* Removes a JSON cache entry.
|
|
682
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
683
683
|
*/
|
|
684
684
|
removeJSON(key) {
|
|
685
685
|
delete this._cache.json[key];
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
/**
|
|
689
|
-
*
|
|
690
|
-
* @param {string} key -
|
|
689
|
+
* Removes an XML cache entry.
|
|
690
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
691
691
|
*/
|
|
692
692
|
removeXML(key) {
|
|
693
693
|
delete this._cache.xml[key];
|
|
694
694
|
}
|
|
695
695
|
|
|
696
696
|
/**
|
|
697
|
-
*
|
|
698
|
-
* @param {string} key -
|
|
697
|
+
* Removes a render texture cache entry.
|
|
698
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
699
699
|
*/
|
|
700
700
|
removeRenderTexture(key) {
|
|
701
701
|
delete this._cache.renderTexture[key];
|
|
702
702
|
}
|
|
703
703
|
|
|
704
704
|
/**
|
|
705
|
-
*
|
|
706
|
-
* @param {string} key -
|
|
705
|
+
* Removes a sprite sheet cache entry.
|
|
706
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
707
707
|
*/
|
|
708
708
|
removeSpriteSheet(key) {
|
|
709
709
|
delete this._cache.spriteSheet[key];
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
/**
|
|
713
|
-
*
|
|
714
|
-
* @param {string} key -
|
|
713
|
+
* Removes a texture atlas cache entry.
|
|
714
|
+
* @param {string} key - The unique key for the cache entry to remove.
|
|
715
715
|
*/
|
|
716
716
|
removeTextureAtlas(key) {
|
|
717
717
|
delete this._cache.atlas[key];
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
/**
|
|
721
|
-
*
|
|
721
|
+
* Clears all GL textures from the cache.
|
|
722
722
|
*/
|
|
723
723
|
clearGLTextures() {
|
|
724
724
|
const keys = Object.keys(this._cache.image);
|
|
@@ -729,10 +729,10 @@ export class Cache {
|
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
/**
|
|
732
|
-
*
|
|
733
|
-
* @param {string} url -
|
|
734
|
-
* @param {object} data -
|
|
735
|
-
* @returns {string}
|
|
732
|
+
* Resolves a URL and stores it in the cache.
|
|
733
|
+
* @param {string} url - The URL to resolve.
|
|
734
|
+
* @param {object} data - The data to associate with the resolved URL.
|
|
735
|
+
* @returns {string} The resolved URL or null if not enabled.
|
|
736
736
|
*/
|
|
737
737
|
_resolveURL(url, data) {
|
|
738
738
|
if (!this.autoResolveURL) {
|
|
@@ -750,7 +750,7 @@ export class Cache {
|
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
/**
|
|
753
|
-
*
|
|
753
|
+
* Destroys the cache and cleans up resources.
|
|
754
754
|
*/
|
|
755
755
|
destroy() {
|
|
756
756
|
for (let i = 0; i < this._cacheMap.length; i += 1) {
|