@vpmedia/phaser 1.112.0 → 1.114.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/dist/index.js +1261 -1314
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +14 -10
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +10 -8
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +5 -4
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +4 -3
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/const.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +3 -2
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +1 -1
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +8 -6
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +40 -30
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +3 -2
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +3 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +6 -4
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +3 -2
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +4 -3
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +9 -8
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +3 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/registry.d.ts +7 -0
- package/dist/phaser/core/registry.d.ts.map +1 -0
- package/dist/phaser/core/scale_manager.d.ts +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +0 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +0 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +4 -3
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +6 -4
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +3 -2
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +5 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -2
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +10 -7
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +3 -2
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +3 -2
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +3 -2
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +3 -2
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +3 -2
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +7 -6
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +10 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -2
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +2 -2
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +14 -12
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +8 -5
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +4 -3
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +13 -10
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +18 -15
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +12 -10
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +7 -6
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +16 -11
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +3 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +4 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +1 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +3 -2
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -2
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/phaser/core/animation.ts +64 -60
- package/src/phaser/core/animation_manager.ts +50 -53
- package/src/phaser/core/animation_parser.ts +9 -9
- package/src/phaser/core/array_set.ts +16 -17
- package/src/phaser/core/cache.ts +92 -93
- package/src/phaser/core/const.ts +1 -1
- package/src/phaser/core/device.ts +24 -29
- package/src/phaser/core/device_util.ts +22 -26
- package/src/phaser/core/dom.ts +54 -65
- package/src/phaser/core/event_manager.ts +64 -94
- package/src/phaser/core/factory.ts +14 -14
- package/src/phaser/core/frame.ts +28 -28
- package/src/phaser/core/frame_data.test.ts +100 -0
- package/src/phaser/core/frame_data.ts +24 -24
- package/src/phaser/core/frame_util.ts +2 -2
- package/src/phaser/core/game.ts +47 -48
- package/src/phaser/core/input.ts +104 -110
- package/src/phaser/core/input_handler.test.ts +113 -0
- package/src/phaser/core/input_handler.ts +199 -218
- package/src/phaser/core/input_mouse.ts +71 -54
- package/src/phaser/core/input_mspointer.ts +52 -39
- package/src/phaser/core/input_pointer.ts +81 -80
- package/src/phaser/core/input_touch.ts +49 -36
- package/src/phaser/core/loader.ts +173 -152
- package/src/phaser/core/loader_parser.ts +39 -57
- package/src/phaser/core/raf.ts +8 -7
- package/src/phaser/core/registry.test.ts +31 -0
- package/src/phaser/core/registry.ts +9 -0
- package/src/phaser/core/scale_manager.ts +156 -152
- package/src/phaser/core/scene.ts +9 -13
- package/src/phaser/core/scene_manager.ts +47 -47
- package/src/phaser/core/signal.test.ts +4 -4
- package/src/phaser/core/signal.ts +41 -52
- package/src/phaser/core/signal_binding.ts +26 -25
- package/src/phaser/core/signal_dispatch.test.ts +180 -0
- package/src/phaser/core/sound.ts +75 -83
- package/src/phaser/core/sound_manager.ts +52 -51
- package/src/phaser/core/sound_sprite.ts +17 -16
- package/src/phaser/core/stage.ts +25 -24
- package/src/phaser/core/time.ts +52 -52
- package/src/phaser/core/timer.test.ts +187 -0
- package/src/phaser/core/timer.ts +82 -69
- package/src/phaser/core/timer_event.ts +10 -10
- package/src/phaser/core/tween.ts +90 -93
- package/src/phaser/core/tween_data.ts +45 -51
- package/src/phaser/core/tween_easing.test.ts +106 -0
- package/src/phaser/core/tween_easing.ts +151 -123
- package/src/phaser/core/tween_manager.ts +19 -18
- package/src/phaser/core/world.ts +4 -3
- package/src/phaser/display/bitmap_text.ts +56 -64
- package/src/phaser/display/button.ts +33 -32
- package/src/phaser/display/canvas/buffer.ts +8 -8
- package/src/phaser/display/canvas/graphics.ts +36 -37
- package/src/phaser/display/canvas/masker.ts +2 -2
- package/src/phaser/display/canvas/pool.test.ts +106 -0
- package/src/phaser/display/canvas/pool.ts +25 -27
- package/src/phaser/display/canvas/renderer.ts +32 -31
- package/src/phaser/display/canvas/tinter.ts +25 -25
- package/src/phaser/display/canvas/util.ts +7 -10
- package/src/phaser/display/display_object.ts +114 -118
- package/src/phaser/display/graphics.ts +121 -119
- package/src/phaser/display/graphics_data.ts +12 -12
- package/src/phaser/display/graphics_data_util.ts +2 -3
- package/src/phaser/display/group.ts +50 -57
- package/src/phaser/display/image.ts +55 -52
- package/src/phaser/display/sprite_batch.ts +3 -2
- package/src/phaser/display/sprite_util.ts +48 -54
- package/src/phaser/display/text.test.ts +110 -0
- package/src/phaser/display/text.ts +199 -204
- package/src/phaser/display/webgl/abstract_filter.ts +9 -9
- package/src/phaser/display/webgl/base_texture.ts +21 -24
- package/src/phaser/display/webgl/blend_manager.ts +6 -10
- package/src/phaser/display/webgl/earcut.ts +73 -37
- package/src/phaser/display/webgl/earcut_node.ts +10 -10
- package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
- package/src/phaser/display/webgl/filter_manager.ts +13 -12
- package/src/phaser/display/webgl/filter_texture.ts +14 -13
- package/src/phaser/display/webgl/graphics.ts +51 -57
- package/src/phaser/display/webgl/graphics_data.ts +15 -14
- package/src/phaser/display/webgl/mask_manager.ts +2 -2
- package/src/phaser/display/webgl/render_texture.ts +26 -25
- package/src/phaser/display/webgl/renderer.ts +57 -62
- package/src/phaser/display/webgl/shader/complex.ts +28 -12
- package/src/phaser/display/webgl/shader/fast.ts +30 -12
- package/src/phaser/display/webgl/shader/normal.ts +70 -57
- package/src/phaser/display/webgl/shader/primitive.ts +26 -11
- package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
- package/src/phaser/display/webgl/shader/strip.ts +27 -12
- package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
- package/src/phaser/display/webgl/shader_manager.ts +26 -34
- package/src/phaser/display/webgl/sprite_batch.ts +67 -61
- package/src/phaser/display/webgl/stencil_manager.ts +23 -34
- package/src/phaser/display/webgl/texture.ts +43 -50
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +26 -25
- package/src/phaser/geom/circle.test.ts +2 -3
- package/src/phaser/geom/circle.ts +36 -36
- package/src/phaser/geom/ellipse.test.ts +73 -71
- package/src/phaser/geom/ellipse.ts +14 -14
- package/src/phaser/geom/line.test.ts +5 -5
- package/src/phaser/geom/line.ts +35 -35
- package/src/phaser/geom/matrix.test.ts +1 -1
- package/src/phaser/geom/matrix.ts +27 -27
- package/src/phaser/geom/point.test.ts +1 -2
- package/src/phaser/geom/point.ts +35 -35
- package/src/phaser/geom/polygon.test.ts +82 -0
- package/src/phaser/geom/polygon.ts +16 -16
- package/src/phaser/geom/rectangle.test.ts +14 -14
- package/src/phaser/geom/rectangle.ts +83 -75
- package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
- package/src/phaser/geom/rounded_rectangle.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +25 -23
- package/src/phaser/geom/util/circle.ts +9 -18
- package/src/phaser/geom/util/ellipse.test.ts +7 -5
- package/src/phaser/geom/util/ellipse.ts +3 -2
- package/src/phaser/geom/util/line.test.ts +10 -8
- package/src/phaser/geom/util/line.ts +6 -16
- package/src/phaser/geom/util/matrix.test.ts +20 -18
- package/src/phaser/geom/util/matrix.ts +8 -15
- package/src/phaser/geom/util/point.test.ts +8 -6
- package/src/phaser/geom/util/point.ts +24 -28
- package/src/phaser/geom/util/polygon.test.ts +12 -10
- package/src/phaser/geom/util/polygon.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +10 -8
- package/src/phaser/geom/util/rectangle.ts +18 -37
- package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.test.ts +11 -11
- package/src/phaser/util/math.ts +29 -46
package/src/phaser/core/cache.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Frame } from './frame.js';
|
|
|
5
5
|
import { FrameData } from './frame_data.js';
|
|
6
6
|
import { jsonBitmapFont, xmlBitmapFont } from './loader_parser.js';
|
|
7
7
|
import { Signal } from './signal.js';
|
|
8
|
+
import type { Game } from './game.js';
|
|
8
9
|
|
|
9
10
|
export const CANVAS = 0;
|
|
10
11
|
export const IMAGE = 1;
|
|
@@ -31,19 +32,19 @@ interface CacheBuckets {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export class Cache {
|
|
34
|
-
game!: any;
|
|
35
|
-
autoResolveURL!: any;
|
|
36
|
-
_cache!: CacheBuckets;
|
|
37
|
-
_urlMap!: any;
|
|
38
|
-
_urlResolver!: any;
|
|
39
|
-
_urlTemp!: any;
|
|
40
|
-
onSoundUnlock!: any;
|
|
41
|
-
_cacheMap!: Record<string, any>[];
|
|
35
|
+
public game!: any;
|
|
36
|
+
public autoResolveURL!: any;
|
|
37
|
+
public _cache!: CacheBuckets;
|
|
38
|
+
public _urlMap!: any;
|
|
39
|
+
public _urlResolver!: any;
|
|
40
|
+
public _urlTemp!: any;
|
|
41
|
+
public onSoundUnlock!: any;
|
|
42
|
+
public _cacheMap!: Record<string, any>[];
|
|
42
43
|
/**
|
|
43
44
|
* Creates a new Cache instance.
|
|
44
|
-
* @param {
|
|
45
|
+
* @param {Game} game - The game instance.
|
|
45
46
|
*/
|
|
46
|
-
constructor(game:
|
|
47
|
+
public constructor(game: Game) {
|
|
47
48
|
this.game = game;
|
|
48
49
|
this.autoResolveURL = false;
|
|
49
50
|
this._cache = {
|
|
@@ -80,24 +81,24 @@ export class Cache {
|
|
|
80
81
|
/**
|
|
81
82
|
* Adds the default image to the cache.
|
|
82
83
|
*/
|
|
83
|
-
addDefaultImage() {
|
|
84
|
+
public addDefaultImage() {
|
|
84
85
|
const img = new Image();
|
|
85
86
|
img.src =
|
|
86
87
|
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==';
|
|
87
88
|
const obj = this.addImage('__default', null, img);
|
|
88
89
|
obj.base.skipRender = true; // invisible texture
|
|
89
|
-
|
|
90
|
+
globalThis.PhaserRegistry.CACHE_DEFAULT_IMAGE = new Texture(obj.base);
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* Adds the missing image to the cache.
|
|
94
95
|
*/
|
|
95
|
-
addMissingImage() {
|
|
96
|
+
public addMissingImage() {
|
|
96
97
|
const img = new Image();
|
|
97
98
|
img.src =
|
|
98
99
|
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==';
|
|
99
100
|
const obj = this.addImage('__missing', null, img);
|
|
100
|
-
|
|
101
|
+
globalThis.PhaserRegistry.CACHE_MISSING_IMAGE = new Texture(obj.base);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
/**
|
|
@@ -107,7 +108,7 @@ export class Cache {
|
|
|
107
108
|
* @param {HTMLImageElement} data - The image data to cache.
|
|
108
109
|
* @returns {object} The cached image object.
|
|
109
110
|
*/
|
|
110
|
-
addImage(key: string, url: string | null, data: HTMLImageElement) {
|
|
111
|
+
public addImage(key: string, url: string | null, data: HTMLImageElement) {
|
|
111
112
|
const resolvedUrl = url ?? '';
|
|
112
113
|
if (this.checkImageKey(key)) {
|
|
113
114
|
this.removeImage(key);
|
|
@@ -140,15 +141,15 @@ export class Cache {
|
|
|
140
141
|
* @param {number} margin - The margin around each frame in pixels.
|
|
141
142
|
* @param {number} spacing - The spacing between frames in pixels.
|
|
142
143
|
*/
|
|
143
|
-
addSpriteSheet(
|
|
144
|
+
public addSpriteSheet(
|
|
144
145
|
key: string,
|
|
145
146
|
url: string,
|
|
146
147
|
data: HTMLImageElement,
|
|
147
148
|
frameWidth: number,
|
|
148
149
|
frameHeight: number,
|
|
149
|
-
frameMax
|
|
150
|
-
margin
|
|
151
|
-
spacing
|
|
150
|
+
frameMax = -1,
|
|
151
|
+
margin = 0,
|
|
152
|
+
spacing = 0
|
|
152
153
|
) {
|
|
153
154
|
const obj = {
|
|
154
155
|
key,
|
|
@@ -168,7 +169,7 @@ export class Cache {
|
|
|
168
169
|
* @param {HTMLCanvasElement} data - The canvas data for the atlas.
|
|
169
170
|
* @param {object} atlasData - The atlas data to cache.
|
|
170
171
|
*/
|
|
171
|
-
addTextureAtlas(key: string, url: string, data: HTMLCanvasElement, atlasData: any) {
|
|
172
|
+
public addTextureAtlas(key: string, url: string, data: HTMLCanvasElement, atlasData: any) {
|
|
172
173
|
const obj: any = {
|
|
173
174
|
key,
|
|
174
175
|
url,
|
|
@@ -186,7 +187,7 @@ export class Cache {
|
|
|
186
187
|
* @param {string} url - The URL the sound was loaded from.
|
|
187
188
|
* @param {object} data - The sound data to cache.
|
|
188
189
|
*/
|
|
189
|
-
addSound(key: string, url: string, data: any) {
|
|
190
|
+
public addSound(key: string, url: string, data: any) {
|
|
190
191
|
this._cache.sound[key] = {
|
|
191
192
|
url,
|
|
192
193
|
data,
|
|
@@ -202,7 +203,7 @@ export class Cache {
|
|
|
202
203
|
* @param {string} url - The URL the text was loaded from.
|
|
203
204
|
* @param {string} data - The text data to cache.
|
|
204
205
|
*/
|
|
205
|
-
addText(key: string, url: string, data: string) {
|
|
206
|
+
public addText(key: string, url: string, data: string) {
|
|
206
207
|
this._cache.text[key] = { url, data };
|
|
207
208
|
this._resolveURL(url, this._cache.text[key]);
|
|
208
209
|
}
|
|
@@ -217,14 +218,14 @@ export class Cache {
|
|
|
217
218
|
* @param {number} xSpacing - Horizontal spacing between characters.
|
|
218
219
|
* @param {number} ySpacing - Vertical spacing between characters.
|
|
219
220
|
*/
|
|
220
|
-
addBitmapFont(
|
|
221
|
+
public addBitmapFont(
|
|
221
222
|
key: string,
|
|
222
223
|
url: string,
|
|
223
224
|
data: HTMLCanvasElement,
|
|
224
225
|
atlasData: any,
|
|
225
226
|
atlasType: string,
|
|
226
|
-
xSpacing
|
|
227
|
-
ySpacing
|
|
227
|
+
xSpacing = 0,
|
|
228
|
+
ySpacing = 0
|
|
228
229
|
) {
|
|
229
230
|
const obj: { url: string; data: unknown; font: object | null; base: BaseTexture } = {
|
|
230
231
|
url,
|
|
@@ -247,7 +248,7 @@ export class Cache {
|
|
|
247
248
|
* @param {string} url - The URL the JSON was loaded from.
|
|
248
249
|
* @param {object} data - The JSON data to cache.
|
|
249
250
|
*/
|
|
250
|
-
addJSON(key: string, url: string, data: any) {
|
|
251
|
+
public addJSON(key: string, url: string, data: any) {
|
|
251
252
|
this._cache.json[key] = { url, data };
|
|
252
253
|
this._resolveURL(url, this._cache.json[key]);
|
|
253
254
|
}
|
|
@@ -258,7 +259,7 @@ export class Cache {
|
|
|
258
259
|
* @param {string} url - The URL the XML was loaded from.
|
|
259
260
|
* @param {XMLDocument} data - The XML data to cache.
|
|
260
261
|
*/
|
|
261
|
-
addXML(key: string, url: string, data: XMLDocument) {
|
|
262
|
+
public addXML(key: string, url: string, data: XMLDocument) {
|
|
262
263
|
this._cache.xml[key] = { url, data };
|
|
263
264
|
this._resolveURL(url, this._cache.xml[key]);
|
|
264
265
|
}
|
|
@@ -271,7 +272,7 @@ export class Cache {
|
|
|
271
272
|
* @param {string} property - The property to update.
|
|
272
273
|
* @param {any} value - The new value for the property.
|
|
273
274
|
*/
|
|
274
|
-
updateSound(key: string, property: string, value: any) {
|
|
275
|
+
public updateSound(key: string, property: string, value: any) {
|
|
275
276
|
const sound = this.getSound(key);
|
|
276
277
|
if (sound) {
|
|
277
278
|
sound[property] = value;
|
|
@@ -283,7 +284,7 @@ export class Cache {
|
|
|
283
284
|
* @param {string} key - The unique key for the cached sound.
|
|
284
285
|
* @param {AudioBuffer} data - The decoded audio buffer.
|
|
285
286
|
*/
|
|
286
|
-
decodedSound(key: string, data: AudioBuffer) {
|
|
287
|
+
public decodedSound(key: string, data: AudioBuffer) {
|
|
287
288
|
const sound = this.getSound(key);
|
|
288
289
|
sound.data = data;
|
|
289
290
|
sound.decoded = true;
|
|
@@ -295,7 +296,7 @@ export class Cache {
|
|
|
295
296
|
* @param {string} key - The unique key for the cached sound.
|
|
296
297
|
* @returns {boolean} True if the sound is decoded, false otherwise.
|
|
297
298
|
*/
|
|
298
|
-
isSoundDecoded(key: string) {
|
|
299
|
+
public isSoundDecoded(key: string) {
|
|
299
300
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
300
301
|
if (sound) {
|
|
301
302
|
return sound.decoded;
|
|
@@ -308,7 +309,7 @@ export class Cache {
|
|
|
308
309
|
* @param {string} key - The unique key for the cached sound.
|
|
309
310
|
* @returns {boolean} True if the sound is ready, false otherwise.
|
|
310
311
|
*/
|
|
311
|
-
isSoundReady(key: string) {
|
|
312
|
+
public isSoundReady(key: string) {
|
|
312
313
|
const sound = this.getItem(key, SOUND, 'isSoundDecoded');
|
|
313
314
|
if (sound) {
|
|
314
315
|
return sound.decoded && !this.game.sound.isLocked;
|
|
@@ -324,8 +325,8 @@ export class Cache {
|
|
|
324
325
|
* @param {string} key - The unique key for the cache entry.
|
|
325
326
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
326
327
|
*/
|
|
327
|
-
checkKey(cache: number, key: string) {
|
|
328
|
-
if (this._cacheMap[cache][key]) {
|
|
328
|
+
public checkKey(cache: number, key: string) {
|
|
329
|
+
if (this._cacheMap[cache]?.[key]) {
|
|
329
330
|
return true;
|
|
330
331
|
}
|
|
331
332
|
return false;
|
|
@@ -336,7 +337,7 @@ export class Cache {
|
|
|
336
337
|
* @param {string} url - The URL to check.
|
|
337
338
|
* @returns {boolean} True if the URL has been resolved and cached, false otherwise.
|
|
338
339
|
*/
|
|
339
|
-
checkURL(url: string) {
|
|
340
|
+
public checkURL(url: string) {
|
|
340
341
|
if (this._urlMap[this._resolveURL(url)]) {
|
|
341
342
|
return true;
|
|
342
343
|
}
|
|
@@ -348,7 +349,7 @@ export class Cache {
|
|
|
348
349
|
* @param {string} key - The unique key for the cache entry.
|
|
349
350
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
350
351
|
*/
|
|
351
|
-
checkCanvasKey(key: string) {
|
|
352
|
+
public checkCanvasKey(key: string) {
|
|
352
353
|
return this.checkKey(CANVAS, key);
|
|
353
354
|
}
|
|
354
355
|
|
|
@@ -357,7 +358,7 @@ export class Cache {
|
|
|
357
358
|
* @param {string} key - The unique key for the cache entry.
|
|
358
359
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
359
360
|
*/
|
|
360
|
-
checkImageKey(key: string) {
|
|
361
|
+
public checkImageKey(key: string) {
|
|
361
362
|
return this.checkKey(IMAGE, key);
|
|
362
363
|
}
|
|
363
364
|
|
|
@@ -366,7 +367,7 @@ export class Cache {
|
|
|
366
367
|
* @param {string} key - The unique key for the cache entry.
|
|
367
368
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
368
369
|
*/
|
|
369
|
-
checkTextureKey(key: string) {
|
|
370
|
+
public checkTextureKey(key: string) {
|
|
370
371
|
return this.checkKey(TEXTURE, key);
|
|
371
372
|
}
|
|
372
373
|
|
|
@@ -375,7 +376,7 @@ export class Cache {
|
|
|
375
376
|
* @param {string} key - The unique key for the cache entry.
|
|
376
377
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
377
378
|
*/
|
|
378
|
-
checkSoundKey(key: string) {
|
|
379
|
+
public checkSoundKey(key: string) {
|
|
379
380
|
return this.checkKey(SOUND, key);
|
|
380
381
|
}
|
|
381
382
|
|
|
@@ -384,7 +385,7 @@ export class Cache {
|
|
|
384
385
|
* @param {string} key - The unique key for the cache entry.
|
|
385
386
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
386
387
|
*/
|
|
387
|
-
checkTextKey(key: string) {
|
|
388
|
+
public checkTextKey(key: string) {
|
|
388
389
|
return this.checkKey(TEXT, key);
|
|
389
390
|
}
|
|
390
391
|
|
|
@@ -393,7 +394,7 @@ export class Cache {
|
|
|
393
394
|
* @param {string} key - The unique key for the cache entry.
|
|
394
395
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
395
396
|
*/
|
|
396
|
-
checkBitmapDataKey(key: string) {
|
|
397
|
+
public checkBitmapDataKey(key: string) {
|
|
397
398
|
return this.checkKey(BITMAPDATA, key);
|
|
398
399
|
}
|
|
399
400
|
|
|
@@ -402,7 +403,7 @@ export class Cache {
|
|
|
402
403
|
* @param {string} key - The unique key for the cache entry.
|
|
403
404
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
404
405
|
*/
|
|
405
|
-
checkBitmapFontKey(key: string) {
|
|
406
|
+
public checkBitmapFontKey(key: string) {
|
|
406
407
|
return this.checkKey(BITMAPFONT, key);
|
|
407
408
|
}
|
|
408
409
|
|
|
@@ -411,7 +412,7 @@ export class Cache {
|
|
|
411
412
|
* @param {string} key - The unique key for the cache entry.
|
|
412
413
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
413
414
|
*/
|
|
414
|
-
checkJSONKey(key: string) {
|
|
415
|
+
public checkJSONKey(key: string) {
|
|
415
416
|
return this.checkKey(JSONDATA, key);
|
|
416
417
|
}
|
|
417
418
|
|
|
@@ -420,7 +421,7 @@ export class Cache {
|
|
|
420
421
|
* @param {string} key - The unique key for the cache entry.
|
|
421
422
|
* @returns {boolean} True if the entry exists, false otherwise.
|
|
422
423
|
*/
|
|
423
|
-
checkXMLKey(key: string) {
|
|
424
|
+
public checkXMLKey(key: string) {
|
|
424
425
|
return this.checkKey(XML, key);
|
|
425
426
|
}
|
|
426
427
|
|
|
@@ -434,12 +435,13 @@ export class Cache {
|
|
|
434
435
|
* @param {string} property - TBD.
|
|
435
436
|
* @returns {*} TBD.
|
|
436
437
|
*/
|
|
437
|
-
getItem(key: string, cache: number, _method: string, property: string | null = null) {
|
|
438
|
+
public getItem(key: string, cache: number, _method: string, property: string | null = null) {
|
|
438
439
|
if (this.checkKey(cache, key)) {
|
|
440
|
+
const entry = this._cacheMap[cache]![key];
|
|
439
441
|
if (!property) {
|
|
440
|
-
return
|
|
442
|
+
return entry;
|
|
441
443
|
}
|
|
442
|
-
return
|
|
444
|
+
return entry[property];
|
|
443
445
|
}
|
|
444
446
|
return null;
|
|
445
447
|
}
|
|
@@ -449,7 +451,7 @@ export class Cache {
|
|
|
449
451
|
* @param {string} key - TBD.
|
|
450
452
|
* @returns {HTMLCanvasElement} TBD.
|
|
451
453
|
*/
|
|
452
|
-
getCanvas(key: string) {
|
|
454
|
+
public getCanvas(key: string) {
|
|
453
455
|
return this.getItem(key, CANVAS, 'getCanvas', 'canvas');
|
|
454
456
|
}
|
|
455
457
|
|
|
@@ -459,7 +461,7 @@ export class Cache {
|
|
|
459
461
|
* @param {boolean} full - TBD.
|
|
460
462
|
* @returns {HTMLImageElement} TBD.
|
|
461
463
|
*/
|
|
462
|
-
getImage(key: any = '__default', full
|
|
464
|
+
public getImage(key: any = '__default', full = false) {
|
|
463
465
|
let img = this.getItem(key, IMAGE, 'getImage');
|
|
464
466
|
if (img === null) {
|
|
465
467
|
img = this.getItem('__missing', IMAGE, 'getImage');
|
|
@@ -475,7 +477,7 @@ export class Cache {
|
|
|
475
477
|
* @param {string} key - TBD.
|
|
476
478
|
* @returns {object} TBD.
|
|
477
479
|
*/
|
|
478
|
-
getTextureFrame(key: string) {
|
|
480
|
+
public getTextureFrame(key: string) {
|
|
479
481
|
return this.getItem(key, TEXTURE, 'getTextureFrame', 'frame');
|
|
480
482
|
}
|
|
481
483
|
|
|
@@ -484,7 +486,7 @@ export class Cache {
|
|
|
484
486
|
* @param {string} key - TBD.
|
|
485
487
|
* @returns {object} TBD.
|
|
486
488
|
*/
|
|
487
|
-
getSound(key: string) {
|
|
489
|
+
public getSound(key: string) {
|
|
488
490
|
return this.getItem(key, SOUND, 'getSound');
|
|
489
491
|
}
|
|
490
492
|
|
|
@@ -493,7 +495,7 @@ export class Cache {
|
|
|
493
495
|
* @param {string} key - TBD.
|
|
494
496
|
* @returns {object} TBD.
|
|
495
497
|
*/
|
|
496
|
-
getSoundData(key: string) {
|
|
498
|
+
public getSoundData(key: string) {
|
|
497
499
|
return this.getItem(key, SOUND, 'getSoundData', 'data');
|
|
498
500
|
}
|
|
499
501
|
|
|
@@ -502,7 +504,7 @@ export class Cache {
|
|
|
502
504
|
* @param {string} key - TBD.
|
|
503
505
|
* @returns {object} TBD.
|
|
504
506
|
*/
|
|
505
|
-
getText(key: string) {
|
|
507
|
+
public getText(key: string) {
|
|
506
508
|
return this.getItem(key, TEXT, 'getText', 'data');
|
|
507
509
|
}
|
|
508
510
|
|
|
@@ -511,7 +513,7 @@ export class Cache {
|
|
|
511
513
|
* @param {string} key - TBD.
|
|
512
514
|
* @returns {object} TBD.
|
|
513
515
|
*/
|
|
514
|
-
getBitmapData(key: string) {
|
|
516
|
+
public getBitmapData(key: string) {
|
|
515
517
|
return this.getItem(key, BITMAPDATA, 'getBitmapData', 'data');
|
|
516
518
|
}
|
|
517
519
|
|
|
@@ -520,7 +522,7 @@ export class Cache {
|
|
|
520
522
|
* @param {string} key - TBD.
|
|
521
523
|
* @returns {object} TBD.
|
|
522
524
|
*/
|
|
523
|
-
getBitmapFont(key: string) {
|
|
525
|
+
public getBitmapFont(key: string) {
|
|
524
526
|
return this.getItem(key, BITMAPFONT, 'getBitmapFont');
|
|
525
527
|
}
|
|
526
528
|
|
|
@@ -531,9 +533,9 @@ export class Cache {
|
|
|
531
533
|
* @param {boolean} isClone - Whether to return a deep clone of the cached data.
|
|
532
534
|
* @returns {T} The cached JSON data.
|
|
533
535
|
*/
|
|
534
|
-
getJSON<T = unknown>(key: string, isClone
|
|
536
|
+
public getJSON<T = unknown>(key: string, isClone = false): T {
|
|
535
537
|
const data = this.getItem(key, JSONDATA, 'getJSON', 'data');
|
|
536
|
-
return isClone ?
|
|
538
|
+
return isClone ? structuredClone(data) : data;
|
|
537
539
|
}
|
|
538
540
|
|
|
539
541
|
/**
|
|
@@ -541,16 +543,16 @@ export class Cache {
|
|
|
541
543
|
* @param {string} key - TBD.
|
|
542
544
|
* @returns {XMLDocument} TBD.
|
|
543
545
|
*/
|
|
544
|
-
getXML(key: string) {
|
|
546
|
+
public getXML(key: string) {
|
|
545
547
|
return this.getItem(key, XML, 'getXML', 'data');
|
|
546
548
|
}
|
|
547
549
|
|
|
548
550
|
/**
|
|
549
551
|
* TBD.
|
|
550
552
|
* @param {string} key - TBD.
|
|
551
|
-
* @returns {
|
|
553
|
+
* @returns {RenderTexture} TBD.
|
|
552
554
|
*/
|
|
553
|
-
getRenderTexture(key: string) {
|
|
555
|
+
public getRenderTexture(key: string) {
|
|
554
556
|
return this.getItem(key, RENDER_TEXTURE, 'getRenderTexture');
|
|
555
557
|
}
|
|
556
558
|
|
|
@@ -562,7 +564,7 @@ export class Cache {
|
|
|
562
564
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
563
565
|
* @returns {BaseTexture} The base texture.
|
|
564
566
|
*/
|
|
565
|
-
getBaseTexture(key: string, cache: number = IMAGE) {
|
|
567
|
+
public getBaseTexture(key: string, cache: number = IMAGE) {
|
|
566
568
|
return this.getItem(key, cache, 'getBaseTexture', 'base');
|
|
567
569
|
}
|
|
568
570
|
|
|
@@ -572,7 +574,7 @@ export class Cache {
|
|
|
572
574
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
573
575
|
* @returns {Frame} The frame.
|
|
574
576
|
*/
|
|
575
|
-
getFrame(key: string, cache: number = IMAGE) {
|
|
577
|
+
public getFrame(key: string, cache: number = IMAGE) {
|
|
576
578
|
return this.getItem(key, cache, 'getFrame', 'frame');
|
|
577
579
|
}
|
|
578
580
|
|
|
@@ -582,7 +584,7 @@ export class Cache {
|
|
|
582
584
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
583
585
|
* @returns {number} The number of frames.
|
|
584
586
|
*/
|
|
585
|
-
getFrameCount(key: string, cache: number = IMAGE) {
|
|
587
|
+
public getFrameCount(key: string, cache: number = IMAGE) {
|
|
586
588
|
const data = this.getFrameData(key, cache);
|
|
587
589
|
if (data) {
|
|
588
590
|
return data.total;
|
|
@@ -596,7 +598,7 @@ export class Cache {
|
|
|
596
598
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
597
599
|
* @returns {FrameData | null} The frame data, or null when the entry has none.
|
|
598
600
|
*/
|
|
599
|
-
getFrameData(key: string, cache: number = IMAGE): FrameData | null {
|
|
601
|
+
public getFrameData(key: string, cache: number = IMAGE): FrameData | null {
|
|
600
602
|
return this.getItem(key, cache, 'getFrameData', 'frameData');
|
|
601
603
|
}
|
|
602
604
|
|
|
@@ -606,7 +608,7 @@ export class Cache {
|
|
|
606
608
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
607
609
|
* @returns {boolean} True if the entry has frame data, false otherwise.
|
|
608
610
|
*/
|
|
609
|
-
hasFrameData(key: string, cache: number = IMAGE) {
|
|
611
|
+
public hasFrameData(key: string, cache: number = IMAGE) {
|
|
610
612
|
return this.getItem(key, cache, '', 'frameData') !== null;
|
|
611
613
|
}
|
|
612
614
|
|
|
@@ -616,9 +618,10 @@ export class Cache {
|
|
|
616
618
|
* @param {FrameData} frameData - The new frame data.
|
|
617
619
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
618
620
|
*/
|
|
619
|
-
updateFrameData(key: string, frameData: FrameData, cache: number = IMAGE) {
|
|
620
|
-
|
|
621
|
-
|
|
621
|
+
public updateFrameData(key: string, frameData: FrameData, cache: number = IMAGE) {
|
|
622
|
+
const entry = this._cacheMap[cache]?.[key];
|
|
623
|
+
if (entry) {
|
|
624
|
+
entry.frameData = frameData;
|
|
622
625
|
}
|
|
623
626
|
}
|
|
624
627
|
|
|
@@ -629,7 +632,7 @@ export class Cache {
|
|
|
629
632
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
630
633
|
* @returns {Frame} The frame at the specified index.
|
|
631
634
|
*/
|
|
632
|
-
getFrameByIndex(key: string, index: number, cache: number = IMAGE) {
|
|
635
|
+
public getFrameByIndex(key: string, index: number, cache: number = IMAGE) {
|
|
633
636
|
const data = this.getFrameData(key, cache);
|
|
634
637
|
if (data) {
|
|
635
638
|
return data.getFrame(index);
|
|
@@ -644,7 +647,7 @@ export class Cache {
|
|
|
644
647
|
* @param {number} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
645
648
|
* @returns {Frame} The frame with the specified name.
|
|
646
649
|
*/
|
|
647
|
-
getFrameByName(key: string, name: string, cache: number = IMAGE) {
|
|
650
|
+
public getFrameByName(key: string, name: string, cache: number = IMAGE) {
|
|
648
651
|
const data = this.getFrameData(key, cache);
|
|
649
652
|
if (data) {
|
|
650
653
|
return data.getFrameByName(name);
|
|
@@ -657,7 +660,7 @@ export class Cache {
|
|
|
657
660
|
* @param {string} url - The original URL to resolve.
|
|
658
661
|
* @returns {string} The resolved URL or null if not found.
|
|
659
662
|
*/
|
|
660
|
-
getURL(url: string) {
|
|
663
|
+
public getURL(url: string) {
|
|
661
664
|
const resolvedURL = this._resolveURL(url);
|
|
662
665
|
if (resolvedURL) {
|
|
663
666
|
return this._urlMap[resolvedURL];
|
|
@@ -671,12 +674,11 @@ export class Cache {
|
|
|
671
674
|
* @param {object} cache - The cache type (CANVAS, IMAGE, etc.).
|
|
672
675
|
* @returns {string[]} An array of cache keys.
|
|
673
676
|
*/
|
|
674
|
-
getKeys(cache: any = IMAGE) {
|
|
677
|
+
public getKeys(cache: any = IMAGE) {
|
|
675
678
|
const result = [];
|
|
676
679
|
if (this._cacheMap[cache]) {
|
|
677
680
|
const keys = Object.keys(this._cacheMap[cache]);
|
|
678
|
-
for (
|
|
679
|
-
const key = keys[i];
|
|
681
|
+
for (const key of keys) {
|
|
680
682
|
if (key !== '__default' && key !== '__missing') {
|
|
681
683
|
result.push(key);
|
|
682
684
|
}
|
|
@@ -691,7 +693,7 @@ export class Cache {
|
|
|
691
693
|
* Removes a canvas cache entry.
|
|
692
694
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
693
695
|
*/
|
|
694
|
-
removeCanvas(key: string) {
|
|
696
|
+
public removeCanvas(key: string) {
|
|
695
697
|
delete this._cache.canvas[key];
|
|
696
698
|
}
|
|
697
699
|
|
|
@@ -700,7 +702,7 @@ export class Cache {
|
|
|
700
702
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
701
703
|
* @param {boolean} destroyBaseTexture - Whether to destroy the base texture (default: true).
|
|
702
704
|
*/
|
|
703
|
-
removeImage(key: string, destroyBaseTexture
|
|
705
|
+
public removeImage(key: string, destroyBaseTexture = true) {
|
|
704
706
|
const img = this.getImage(key, true);
|
|
705
707
|
if (destroyBaseTexture && img.base) {
|
|
706
708
|
img.base.destroy();
|
|
@@ -712,7 +714,7 @@ export class Cache {
|
|
|
712
714
|
* Removes a sound cache entry.
|
|
713
715
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
714
716
|
*/
|
|
715
|
-
removeSound(key: string) {
|
|
717
|
+
public removeSound(key: string) {
|
|
716
718
|
delete this._cache.sound[key];
|
|
717
719
|
}
|
|
718
720
|
|
|
@@ -720,7 +722,7 @@ export class Cache {
|
|
|
720
722
|
* Removes a text cache entry.
|
|
721
723
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
722
724
|
*/
|
|
723
|
-
removeText(key: string) {
|
|
725
|
+
public removeText(key: string) {
|
|
724
726
|
delete this._cache.text[key];
|
|
725
727
|
}
|
|
726
728
|
|
|
@@ -728,7 +730,7 @@ export class Cache {
|
|
|
728
730
|
* Removes a bitmap data cache entry.
|
|
729
731
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
730
732
|
*/
|
|
731
|
-
removeBitmapData(key: string) {
|
|
733
|
+
public removeBitmapData(key: string) {
|
|
732
734
|
delete this._cache.bitmapData[key];
|
|
733
735
|
}
|
|
734
736
|
|
|
@@ -736,7 +738,7 @@ export class Cache {
|
|
|
736
738
|
* Removes a bitmap font cache entry.
|
|
737
739
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
738
740
|
*/
|
|
739
|
-
removeBitmapFont(key: string) {
|
|
741
|
+
public removeBitmapFont(key: string) {
|
|
740
742
|
delete this._cache.bitmapFont[key];
|
|
741
743
|
}
|
|
742
744
|
|
|
@@ -744,7 +746,7 @@ export class Cache {
|
|
|
744
746
|
* Removes a JSON cache entry.
|
|
745
747
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
746
748
|
*/
|
|
747
|
-
removeJSON(key: string) {
|
|
749
|
+
public removeJSON(key: string) {
|
|
748
750
|
delete this._cache.json[key];
|
|
749
751
|
}
|
|
750
752
|
|
|
@@ -752,7 +754,7 @@ export class Cache {
|
|
|
752
754
|
* Removes an XML cache entry.
|
|
753
755
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
754
756
|
*/
|
|
755
|
-
removeXML(key: string) {
|
|
757
|
+
public removeXML(key: string) {
|
|
756
758
|
delete this._cache.xml[key];
|
|
757
759
|
}
|
|
758
760
|
|
|
@@ -760,7 +762,7 @@ export class Cache {
|
|
|
760
762
|
* Removes a render texture cache entry.
|
|
761
763
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
762
764
|
*/
|
|
763
|
-
removeRenderTexture(key: string) {
|
|
765
|
+
public removeRenderTexture(key: string) {
|
|
764
766
|
delete this._cache.renderTexture[key];
|
|
765
767
|
}
|
|
766
768
|
|
|
@@ -768,7 +770,7 @@ export class Cache {
|
|
|
768
770
|
* Removes a sprite sheet cache entry.
|
|
769
771
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
770
772
|
*/
|
|
771
|
-
removeSpriteSheet(key: string) {
|
|
773
|
+
public removeSpriteSheet(key: string) {
|
|
772
774
|
delete this._cache.image[key];
|
|
773
775
|
}
|
|
774
776
|
|
|
@@ -776,17 +778,16 @@ export class Cache {
|
|
|
776
778
|
* Removes a texture atlas cache entry.
|
|
777
779
|
* @param {string} key - The unique key for the cache entry to remove.
|
|
778
780
|
*/
|
|
779
|
-
removeTextureAtlas(key: string) {
|
|
781
|
+
public removeTextureAtlas(key: string) {
|
|
780
782
|
delete this._cache.image[key];
|
|
781
783
|
}
|
|
782
784
|
|
|
783
785
|
/**
|
|
784
786
|
* Clears all GL textures from the cache.
|
|
785
787
|
*/
|
|
786
|
-
clearGLTextures() {
|
|
788
|
+
public clearGLTextures() {
|
|
787
789
|
const keys = Object.keys(this._cache.image);
|
|
788
|
-
for (
|
|
789
|
-
const key = keys[i];
|
|
790
|
+
for (const key of keys) {
|
|
790
791
|
this._cache.image[key].base._glTextures = [];
|
|
791
792
|
}
|
|
792
793
|
}
|
|
@@ -797,7 +798,7 @@ export class Cache {
|
|
|
797
798
|
* @param {object} data - The data to associate with the resolved URL.
|
|
798
799
|
* @returns {string} The resolved URL or null if not enabled.
|
|
799
800
|
*/
|
|
800
|
-
_resolveURL(url: string, data: any | null = null) {
|
|
801
|
+
public _resolveURL(url: string, data: any | null = null) {
|
|
801
802
|
if (!this.autoResolveURL) {
|
|
802
803
|
return null;
|
|
803
804
|
}
|
|
@@ -815,12 +816,10 @@ export class Cache {
|
|
|
815
816
|
/**
|
|
816
817
|
* Destroys the cache and cleans up resources.
|
|
817
818
|
*/
|
|
818
|
-
destroy() {
|
|
819
|
-
for (
|
|
820
|
-
const cache = this._cacheMap[i];
|
|
819
|
+
public destroy() {
|
|
820
|
+
for (const cache of this._cacheMap) {
|
|
821
821
|
const keys = cache ? Object.keys(cache) : [];
|
|
822
|
-
for (
|
|
823
|
-
const key = keys[j];
|
|
822
|
+
for (const key of keys) {
|
|
824
823
|
if (key !== '__default' && key !== '__missing') {
|
|
825
824
|
if (cache[key].destroy) {
|
|
826
825
|
cache[key].destroy();
|