@vpmedia/phaser 1.11.0 → 1.13.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/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Signal from
|
|
7
|
-
import Rectangle from
|
|
6
|
+
import { Signal } from './signal';
|
|
7
|
+
import { Rectangle } from '../geom/rectangle';
|
|
8
8
|
import { canPlayAudio } from './device_util';
|
|
9
9
|
|
|
10
10
|
const TEXTURE_ATLAS_JSON_HASH = 1;
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(game) {
|
|
15
14
|
this.game = game;
|
|
16
15
|
this.cache = game.cache;
|
|
@@ -122,7 +121,14 @@ export default class {
|
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
addToFileList(
|
|
124
|
+
addToFileList(
|
|
125
|
+
type,
|
|
126
|
+
key = '',
|
|
127
|
+
url = null,
|
|
128
|
+
properties = null,
|
|
129
|
+
overwrite = false,
|
|
130
|
+
extension = null
|
|
131
|
+
) {
|
|
126
132
|
if (key === undefined || key === '') {
|
|
127
133
|
console.warn('Loader: Invalid or no key given of type ' + type);
|
|
128
134
|
return this;
|
|
@@ -184,7 +190,7 @@ export default class {
|
|
|
184
190
|
loading: false,
|
|
185
191
|
loaded: false,
|
|
186
192
|
error: false,
|
|
187
|
-
callbackContext: callbackContext
|
|
193
|
+
callbackContext: callbackContext,
|
|
188
194
|
};
|
|
189
195
|
if (data) {
|
|
190
196
|
if (typeof data === 'string') {
|
|
@@ -234,7 +240,14 @@ export default class {
|
|
|
234
240
|
}
|
|
235
241
|
|
|
236
242
|
spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
|
|
237
|
-
return this.addToFileList(
|
|
243
|
+
return this.addToFileList(
|
|
244
|
+
'spritesheet',
|
|
245
|
+
key,
|
|
246
|
+
url,
|
|
247
|
+
{ frameWidth, frameHeight, frameMax, margin, spacing },
|
|
248
|
+
false,
|
|
249
|
+
'.png'
|
|
250
|
+
);
|
|
238
251
|
}
|
|
239
252
|
|
|
240
253
|
audio(key, urls, autoDecode = true) {
|
|
@@ -263,7 +276,14 @@ export default class {
|
|
|
263
276
|
return this;
|
|
264
277
|
}
|
|
265
278
|
|
|
266
|
-
bitmapFont(
|
|
279
|
+
bitmapFont(
|
|
280
|
+
key,
|
|
281
|
+
textureURL = null,
|
|
282
|
+
atlasURL = null,
|
|
283
|
+
atlasData = null,
|
|
284
|
+
xSpacing = 0,
|
|
285
|
+
ySpacing = 0
|
|
286
|
+
) {
|
|
267
287
|
if (textureURL === undefined || textureURL === null) {
|
|
268
288
|
textureURL = key + '.png';
|
|
269
289
|
}
|
|
@@ -285,7 +305,13 @@ export default class {
|
|
|
285
305
|
if (!xml && !json) {
|
|
286
306
|
throw new Error('Loader. Invalid Bitmap Font atlas given');
|
|
287
307
|
}
|
|
288
|
-
this.addToFileList('bitmapfont', key, textureURL, {
|
|
308
|
+
this.addToFileList('bitmapfont', key, textureURL, {
|
|
309
|
+
atlasURL: null,
|
|
310
|
+
atlasData: json || xml,
|
|
311
|
+
atlasType: json ? 'json' : 'xml',
|
|
312
|
+
xSpacing,
|
|
313
|
+
ySpacing,
|
|
314
|
+
});
|
|
289
315
|
}
|
|
290
316
|
return this;
|
|
291
317
|
}
|
|
@@ -368,11 +394,22 @@ export default class {
|
|
|
368
394
|
}
|
|
369
395
|
if (file.type !== 'packfile') {
|
|
370
396
|
this._loadedFileCount += 1;
|
|
371
|
-
this.onFileComplete.dispatch(
|
|
397
|
+
this.onFileComplete.dispatch(
|
|
398
|
+
this.progress,
|
|
399
|
+
file.key,
|
|
400
|
+
!file.error,
|
|
401
|
+
this._loadedFileCount,
|
|
402
|
+
this._totalFileCount
|
|
403
|
+
);
|
|
372
404
|
} else if (file.type === 'packfile' && file.error) {
|
|
373
405
|
// Non-error pack files are handled when processing the file queue
|
|
374
406
|
this._loadedPackCount += 1;
|
|
375
|
-
this.onPackComplete.dispatch(
|
|
407
|
+
this.onPackComplete.dispatch(
|
|
408
|
+
file.key,
|
|
409
|
+
!file.error,
|
|
410
|
+
this._loadedPackCount,
|
|
411
|
+
this._totalPackCount
|
|
412
|
+
);
|
|
376
413
|
}
|
|
377
414
|
}
|
|
378
415
|
}
|
|
@@ -386,7 +423,12 @@ export default class {
|
|
|
386
423
|
// Processing the pack / adds more files
|
|
387
424
|
this.processPack(file);
|
|
388
425
|
this._loadedPackCount += 1;
|
|
389
|
-
this.onPackComplete.dispatch(
|
|
426
|
+
this.onPackComplete.dispatch(
|
|
427
|
+
file.key,
|
|
428
|
+
!file.error,
|
|
429
|
+
this._loadedPackCount,
|
|
430
|
+
this._totalPackCount
|
|
431
|
+
);
|
|
390
432
|
}
|
|
391
433
|
if (file.loaded || file.error) {
|
|
392
434
|
// Item at the start of file list finished, can skip it in future
|
|
@@ -417,7 +459,10 @@ export default class {
|
|
|
417
459
|
}
|
|
418
460
|
// Stop looking if queue full - or if syncblocked and there are no more packs.
|
|
419
461
|
// (As only packs can be loaded around a syncblock)
|
|
420
|
-
if (
|
|
462
|
+
if (
|
|
463
|
+
this._flightQueue.length >= inflightLimit ||
|
|
464
|
+
(syncblock && this._loadedPackCount === this._totalPackCount)
|
|
465
|
+
) {
|
|
421
466
|
break;
|
|
422
467
|
}
|
|
423
468
|
}
|
|
@@ -477,35 +522,56 @@ export default class {
|
|
|
477
522
|
for (let i = 0; i < packDataCompat.length; i += 1) {
|
|
478
523
|
const file = packDataCompat[i];
|
|
479
524
|
switch (file.type) {
|
|
480
|
-
case
|
|
525
|
+
case 'image':
|
|
481
526
|
this.image(file.key, file.url, file.overwrite);
|
|
482
527
|
break;
|
|
483
|
-
case
|
|
528
|
+
case 'text':
|
|
484
529
|
this.text(file.key, file.url, file.overwrite);
|
|
485
530
|
break;
|
|
486
|
-
case
|
|
531
|
+
case 'json':
|
|
487
532
|
this.json(file.key, file.url, file.overwrite);
|
|
488
533
|
break;
|
|
489
|
-
case
|
|
534
|
+
case 'xml':
|
|
490
535
|
this.xml(file.key, file.url, file.overwrite);
|
|
491
536
|
break;
|
|
492
|
-
case
|
|
493
|
-
this.spritesheet(
|
|
537
|
+
case 'spritesheet':
|
|
538
|
+
this.spritesheet(
|
|
539
|
+
file.key,
|
|
540
|
+
file.url,
|
|
541
|
+
file.frameWidth,
|
|
542
|
+
file.frameHeight,
|
|
543
|
+
file.frameMax,
|
|
544
|
+
file.margin,
|
|
545
|
+
file.spacing
|
|
546
|
+
);
|
|
494
547
|
break;
|
|
495
|
-
case
|
|
548
|
+
case 'audio':
|
|
496
549
|
this.audio(file.key, file.urls ? file.urls : file.url);
|
|
497
550
|
break;
|
|
498
|
-
case
|
|
551
|
+
case 'audiosprite':
|
|
499
552
|
this.audioSprite(file.key, file.urls ? file.urls : file.url, file.jsonURL, file.jsonData);
|
|
500
553
|
break;
|
|
501
|
-
case
|
|
554
|
+
case 'audioSprite':
|
|
502
555
|
this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
|
|
503
556
|
break;
|
|
504
|
-
case
|
|
505
|
-
this.bitmapFont(
|
|
557
|
+
case 'bitmapFont':
|
|
558
|
+
this.bitmapFont(
|
|
559
|
+
file.key,
|
|
560
|
+
file.textureURL,
|
|
561
|
+
file.fontDataURL ? file.fontDataURL : file.atlasURL,
|
|
562
|
+
file.atlasData,
|
|
563
|
+
file.xSpacing,
|
|
564
|
+
file.ySpacing
|
|
565
|
+
);
|
|
506
566
|
break;
|
|
507
|
-
case
|
|
508
|
-
this.atlas(
|
|
567
|
+
case 'atlas':
|
|
568
|
+
this.atlas(
|
|
569
|
+
file.key,
|
|
570
|
+
file.textureURL,
|
|
571
|
+
file.atlasURL,
|
|
572
|
+
file.atlasData,
|
|
573
|
+
TEXTURE_ATLAS_JSON_HASH
|
|
574
|
+
);
|
|
509
575
|
break;
|
|
510
576
|
}
|
|
511
577
|
}
|
|
@@ -537,7 +603,11 @@ export default class {
|
|
|
537
603
|
if (file.url) {
|
|
538
604
|
this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
|
|
539
605
|
} else {
|
|
540
|
-
this.fileError(
|
|
606
|
+
this.fileError(
|
|
607
|
+
file,
|
|
608
|
+
null,
|
|
609
|
+
'No supported audio URL specified or device does not have audio playback support'
|
|
610
|
+
);
|
|
541
611
|
}
|
|
542
612
|
break;
|
|
543
613
|
case 'json':
|
|
@@ -572,7 +642,7 @@ export default class {
|
|
|
572
642
|
};
|
|
573
643
|
file.data.onerror = () => {
|
|
574
644
|
if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
|
|
575
|
-
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
645
|
+
file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
|
|
576
646
|
scope.loadImageTag(file);
|
|
577
647
|
} else if (file.data.onload) {
|
|
578
648
|
file.data.onload = null;
|
|
@@ -598,9 +668,10 @@ export default class {
|
|
|
598
668
|
onerror = onerror || this.fileError;
|
|
599
669
|
xhr.onload = () => {
|
|
600
670
|
try {
|
|
601
|
-
if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) {
|
|
671
|
+
if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) {
|
|
672
|
+
// Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
|
|
602
673
|
if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
|
|
603
|
-
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
674
|
+
file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
|
|
604
675
|
scope.xhrLoad(file, url, type, onload, onerror);
|
|
605
676
|
return null;
|
|
606
677
|
} else {
|
|
@@ -621,7 +692,7 @@ export default class {
|
|
|
621
692
|
};
|
|
622
693
|
xhr.onerror = () => {
|
|
623
694
|
if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
|
|
624
|
-
file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
|
|
695
|
+
file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
|
|
625
696
|
scope.xhrLoad(file, url, type, onload, onerror);
|
|
626
697
|
} else {
|
|
627
698
|
try {
|
|
@@ -702,7 +773,16 @@ export default class {
|
|
|
702
773
|
this.cache.addImage(file.key, file.url, file.data);
|
|
703
774
|
break;
|
|
704
775
|
case 'spritesheet':
|
|
705
|
-
this.cache.addSpriteSheet(
|
|
776
|
+
this.cache.addSpriteSheet(
|
|
777
|
+
file.key,
|
|
778
|
+
file.url,
|
|
779
|
+
file.data,
|
|
780
|
+
file.frameWidth,
|
|
781
|
+
file.frameHeight,
|
|
782
|
+
file.frameMax,
|
|
783
|
+
file.margin,
|
|
784
|
+
file.spacing
|
|
785
|
+
);
|
|
706
786
|
break;
|
|
707
787
|
case 'textureatlas':
|
|
708
788
|
if (file.atlasURL == null) {
|
|
@@ -710,7 +790,12 @@ export default class {
|
|
|
710
790
|
} else {
|
|
711
791
|
loadNext = false;
|
|
712
792
|
if (file.format === TEXTURE_ATLAS_JSON_HASH) {
|
|
713
|
-
this.xhrLoad(
|
|
793
|
+
this.xhrLoad(
|
|
794
|
+
file,
|
|
795
|
+
this.transformUrl(file.atlasURL, file),
|
|
796
|
+
'text',
|
|
797
|
+
this.jsonLoadComplete
|
|
798
|
+
);
|
|
714
799
|
} else {
|
|
715
800
|
throw new Error('Invalid Texture Atlas format: ' + file.format);
|
|
716
801
|
}
|
|
@@ -718,26 +803,39 @@ export default class {
|
|
|
718
803
|
break;
|
|
719
804
|
case 'bitmapfont':
|
|
720
805
|
if (!file.atlasURL) {
|
|
721
|
-
this.cache.addBitmapFont(
|
|
806
|
+
this.cache.addBitmapFont(
|
|
807
|
+
file.key,
|
|
808
|
+
file.url,
|
|
809
|
+
file.data,
|
|
810
|
+
file.atlasData,
|
|
811
|
+
file.atlasType,
|
|
812
|
+
file.xSpacing,
|
|
813
|
+
file.ySpacing
|
|
814
|
+
);
|
|
722
815
|
} else {
|
|
723
816
|
// Load the XML before carrying on with the next file
|
|
724
817
|
loadNext = false;
|
|
725
|
-
this.xhrLoad(
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
818
|
+
this.xhrLoad(
|
|
819
|
+
file,
|
|
820
|
+
this.transformUrl(file.atlasURL, file),
|
|
821
|
+
'text',
|
|
822
|
+
(bitmapFontFile, bitmapFontXhr) => {
|
|
823
|
+
let json;
|
|
824
|
+
try {
|
|
825
|
+
// Try to parse as JSON, if it fails, then it's hopefully XML
|
|
826
|
+
json = JSON.parse(bitmapFontXhr.responseText);
|
|
827
|
+
} catch (e) {
|
|
828
|
+
// pass
|
|
829
|
+
}
|
|
830
|
+
if (json) {
|
|
831
|
+
bitmapFontFile.atlasType = 'json';
|
|
832
|
+
this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
|
|
833
|
+
} else {
|
|
834
|
+
bitmapFontFile.atlasType = 'xml';
|
|
835
|
+
this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
|
|
836
|
+
}
|
|
739
837
|
}
|
|
740
|
-
|
|
838
|
+
);
|
|
741
839
|
}
|
|
742
840
|
break;
|
|
743
841
|
case 'audio':
|
|
@@ -763,7 +861,15 @@ export default class {
|
|
|
763
861
|
jsonLoadComplete(file, xhr) {
|
|
764
862
|
const data = JSON.parse(xhr.responseText);
|
|
765
863
|
if (file.type === 'bitmapfont') {
|
|
766
|
-
this.cache.addBitmapFont(
|
|
864
|
+
this.cache.addBitmapFont(
|
|
865
|
+
file.key,
|
|
866
|
+
file.url,
|
|
867
|
+
file.data,
|
|
868
|
+
data,
|
|
869
|
+
file.atlasType,
|
|
870
|
+
file.xSpacing,
|
|
871
|
+
file.ySpacing
|
|
872
|
+
);
|
|
767
873
|
} else if (file.type === 'json') {
|
|
768
874
|
this.cache.addJSON(file.key, file.url, data);
|
|
769
875
|
} else {
|
|
@@ -788,7 +894,15 @@ export default class {
|
|
|
788
894
|
return;
|
|
789
895
|
}
|
|
790
896
|
if (file.type === 'bitmapfont') {
|
|
791
|
-
this.cache.addBitmapFont(
|
|
897
|
+
this.cache.addBitmapFont(
|
|
898
|
+
file.key,
|
|
899
|
+
file.url,
|
|
900
|
+
file.data,
|
|
901
|
+
xml,
|
|
902
|
+
file.atlasType,
|
|
903
|
+
file.xSpacing,
|
|
904
|
+
file.ySpacing
|
|
905
|
+
);
|
|
792
906
|
} else if (file.type === 'textureatlas') {
|
|
793
907
|
this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
|
|
794
908
|
} else if (file.type === 'xml') {
|
|
@@ -821,9 +935,13 @@ export default class {
|
|
|
821
935
|
updateProgress() {
|
|
822
936
|
if (this.preloadSprite) {
|
|
823
937
|
if (this.preloadSprite.direction === 0) {
|
|
824
|
-
this.preloadSprite.rect.width = Math.floor(
|
|
938
|
+
this.preloadSprite.rect.width = Math.floor(
|
|
939
|
+
(this.preloadSprite.width / 100) * this.progress
|
|
940
|
+
);
|
|
825
941
|
} else {
|
|
826
|
-
this.preloadSprite.rect.height = Math.floor(
|
|
942
|
+
this.preloadSprite.rect.height = Math.floor(
|
|
943
|
+
(this.preloadSprite.height / 100) * this.progress
|
|
944
|
+
);
|
|
827
945
|
}
|
|
828
946
|
if (this.preloadSprite.sprite) {
|
|
829
947
|
this.preloadSprite.sprite.updateCrop();
|
|
@@ -865,5 +983,4 @@ export default class {
|
|
|
865
983
|
get progress() {
|
|
866
984
|
return Math.round(this.progressFloat);
|
|
867
985
|
}
|
|
868
|
-
|
|
869
986
|
}
|
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
import Texture from '../display/webgl/texture';
|
|
7
|
-
import Rectangle from
|
|
6
|
+
import { Texture } from '../display/webgl/texture';
|
|
7
|
+
import { Rectangle } from '../geom/rectangle';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* TBD.
|
|
10
11
|
*
|
|
11
|
-
* @param {object} baseTexture TBD
|
|
12
|
-
* @param {object} bitmapFontData TBD
|
|
13
|
-
* @returns {object} TBD
|
|
12
|
+
* @param {object} baseTexture - TBD.
|
|
13
|
+
* @param {object} bitmapFontData - TBD.
|
|
14
|
+
* @returns {object} TBD.
|
|
14
15
|
*/
|
|
15
16
|
export function finalizeBitmapFont(baseTexture, bitmapFontData) {
|
|
16
17
|
Object.keys(bitmapFontData.chars).forEach((charCode) => {
|
|
17
18
|
const letter = bitmapFontData.chars[charCode];
|
|
18
|
-
letter.texture = new Texture(
|
|
19
|
+
letter.texture = new Texture(
|
|
20
|
+
baseTexture,
|
|
21
|
+
new Rectangle(letter.x, letter.y, letter.width, letter.height)
|
|
22
|
+
);
|
|
19
23
|
});
|
|
20
24
|
return bitmapFontData;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
28
|
+
* TBD.
|
|
24
29
|
*
|
|
25
|
-
* @param {object} xml TBD
|
|
26
|
-
* @param {object} baseTexture TBD
|
|
27
|
-
* @param {number} xSpacing TBD
|
|
28
|
-
* @param {number} ySpacing TBD
|
|
29
|
-
* @returns {object} TBD
|
|
30
|
+
* @param {object} xml - TBD.
|
|
31
|
+
* @param {object} baseTexture - TBD.
|
|
32
|
+
* @param {number} xSpacing - TBD.
|
|
33
|
+
* @param {number} ySpacing - TBD.
|
|
34
|
+
* @returns {object} TBD.
|
|
30
35
|
*/
|
|
31
36
|
export function xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing) {
|
|
32
37
|
const data = {};
|
|
@@ -61,24 +66,26 @@ export function xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing) {
|
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
/**
|
|
69
|
+
* TBD.
|
|
64
70
|
*
|
|
65
|
-
* @param {object} xml TBD
|
|
66
|
-
* @param {object} baseTexture TBD
|
|
67
|
-
* @param {number} xSpacing TBD
|
|
68
|
-
* @param {number} ySpacing TBD
|
|
69
|
-
* @returns {object} TBD
|
|
71
|
+
* @param {object} xml - TBD.
|
|
72
|
+
* @param {object} baseTexture - TBD.
|
|
73
|
+
* @param {number} xSpacing - TBD.
|
|
74
|
+
* @param {number} ySpacing - TBD.
|
|
75
|
+
* @returns {object} TBD.
|
|
70
76
|
*/
|
|
71
77
|
export function bitmapFont(xml, baseTexture, xSpacing, ySpacing) {
|
|
72
78
|
return xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing);
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
/**
|
|
82
|
+
* TBD.
|
|
76
83
|
*
|
|
77
|
-
* @param {object} json TBD
|
|
78
|
-
* @param {object} baseTexture TBD
|
|
79
|
-
* @param {number} xSpacing TBD
|
|
80
|
-
* @param {number} ySpacing TBD
|
|
81
|
-
* @returns {object} TBD
|
|
84
|
+
* @param {object} json - TBD.
|
|
85
|
+
* @param {object} baseTexture - TBD.
|
|
86
|
+
* @param {number} xSpacing - TBD.
|
|
87
|
+
* @param {number} ySpacing - TBD.
|
|
88
|
+
* @returns {object} TBD.
|
|
82
89
|
*/
|
|
83
90
|
export function jsonBitmapFont(json, baseTexture, xSpacing, ySpacing) {
|
|
84
91
|
const data = {
|
package/src/phaser/core/raf.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export class RequestAnimationFrame {
|
|
8
7
|
constructor(game) {
|
|
9
8
|
this.game = game;
|
|
10
9
|
this.rafId = 0;
|
|
@@ -23,5 +22,4 @@ export default class {
|
|
|
23
22
|
this.game.update(rafTime);
|
|
24
23
|
this.rafId = requestAnimationFrame(this.updateBinded);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
}
|