@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,22 @@
|
|
|
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
|
|
6
|
+
import { Signal } from './signal';
|
|
7
7
|
import DOM from './dom';
|
|
8
|
-
import Point from '../geom/point';
|
|
9
|
-
import Rectangle from
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { Point } from '../geom/point';
|
|
9
|
+
import { Rectangle } from '../geom/rectangle';
|
|
10
|
+
import {
|
|
11
|
+
SCALE_OFF,
|
|
12
|
+
SCALE_RESIZE,
|
|
13
|
+
SCALE_EXACT_FIT,
|
|
14
|
+
SCALE_USER,
|
|
15
|
+
SCALE_SHOW_ALL,
|
|
16
|
+
RENDER_CANVAS,
|
|
17
|
+
} from './const';
|
|
18
|
+
|
|
19
|
+
export class ScaleManager {
|
|
14
20
|
constructor(game, width, height) {
|
|
15
21
|
this.game = game;
|
|
16
22
|
this.dom = new DOM(game.device);
|
|
@@ -102,14 +108,14 @@ export default class {
|
|
|
102
108
|
}
|
|
103
109
|
// Configure event listeners
|
|
104
110
|
const scope = this;
|
|
105
|
-
this._orientationChange = event => scope.orientationChange(event);
|
|
106
|
-
this._windowResize = event => scope.windowResize(event);
|
|
111
|
+
this._orientationChange = (event) => scope.orientationChange(event);
|
|
112
|
+
this._windowResize = (event) => scope.windowResize(event);
|
|
107
113
|
// This does not appear to be on the standards track
|
|
108
114
|
window.addEventListener('orientationchange', this._orientationChange, false);
|
|
109
115
|
window.addEventListener('resize', this._windowResize, false);
|
|
110
116
|
if (this.compatibility.supportsFullScreen) {
|
|
111
|
-
this._fullScreenChange = event => scope.fullScreenChange(event);
|
|
112
|
-
this._fullScreenError = event => scope.fullScreenError(event);
|
|
117
|
+
this._fullScreenChange = (event) => scope.fullScreenChange(event);
|
|
118
|
+
this._fullScreenError = (event) => scope.fullScreenError(event);
|
|
113
119
|
document.addEventListener('webkitfullscreenchange', this._fullScreenChange, false);
|
|
114
120
|
document.addEventListener('mozfullscreenchange', this._fullScreenChange, false);
|
|
115
121
|
document.addEventListener('MSFullscreenChange', this._fullScreenChange, false);
|
|
@@ -225,7 +231,12 @@ export default class {
|
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
signalSizeChange() {
|
|
228
|
-
if (
|
|
234
|
+
if (
|
|
235
|
+
this.width !== this._lastReportedCanvasSize.width ||
|
|
236
|
+
this.height !== this._lastReportedCanvasSize.height ||
|
|
237
|
+
this.game.width !== this._lastReportedGameSize.width ||
|
|
238
|
+
this.game.height !== this._lastReportedGameSize.height
|
|
239
|
+
) {
|
|
229
240
|
const width = this.width;
|
|
230
241
|
const height = this.height;
|
|
231
242
|
this._lastReportedCanvasSize.setTo(0, 0, width, height);
|
|
@@ -251,7 +262,7 @@ export default class {
|
|
|
251
262
|
}
|
|
252
263
|
|
|
253
264
|
preUpdate() {
|
|
254
|
-
if (this.game.time.time <
|
|
265
|
+
if (this.game.time.time < this._lastUpdate + this._updateThrottle) {
|
|
255
266
|
return;
|
|
256
267
|
}
|
|
257
268
|
const prevThrottle = this._updateThrottle;
|
|
@@ -335,7 +346,8 @@ export default class {
|
|
|
335
346
|
const previousOrientation = this.screenOrientation;
|
|
336
347
|
const previouslyIncorrect = this.incorrectOrientation;
|
|
337
348
|
this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback);
|
|
338
|
-
this.incorrectOrientation =
|
|
349
|
+
this.incorrectOrientation =
|
|
350
|
+
(this.forceLandscape && !this.isLandscape) || (this.forcePortrait && !this.isPortrait);
|
|
339
351
|
const changed = previousOrientation !== this.screenOrientation;
|
|
340
352
|
const correctnessChanged = previouslyIncorrect !== this.incorrectOrientation;
|
|
341
353
|
if (correctnessChanged) {
|
|
@@ -390,10 +402,13 @@ export default class {
|
|
|
390
402
|
this.width = this.game.width;
|
|
391
403
|
this.height = this.game.height;
|
|
392
404
|
} else if (scaleMode === SCALE_USER) {
|
|
393
|
-
this.width =
|
|
394
|
-
this.height =
|
|
405
|
+
this.width = this.game.width * this._userScaleFactor.x - this._userScaleTrim.x;
|
|
406
|
+
this.height = this.game.height * this._userScaleFactor.y - this._userScaleTrim.y;
|
|
395
407
|
}
|
|
396
|
-
if (
|
|
408
|
+
if (
|
|
409
|
+
!this.compatibility.canExpandParent &&
|
|
410
|
+
(scaleMode === SCALE_SHOW_ALL || scaleMode === SCALE_USER)
|
|
411
|
+
) {
|
|
397
412
|
const bounds = this.getParentBounds(this._tempBounds);
|
|
398
413
|
this.width = Math.min(this.width, bounds.width);
|
|
399
414
|
this.height = Math.min(this.height, bounds.height);
|
|
@@ -414,8 +429,15 @@ export default class {
|
|
|
414
429
|
} else {
|
|
415
430
|
// Ref. http://msdn.microsoft.com/en-us/library/hh781509(v=vs.85).aspx for getBoundingClientRect
|
|
416
431
|
const clientRect = parentNode.getBoundingClientRect();
|
|
417
|
-
const parentRect =
|
|
418
|
-
|
|
432
|
+
const parentRect = parentNode.offsetParent
|
|
433
|
+
? parentNode.offsetParent.getBoundingClientRect()
|
|
434
|
+
: parentNode.getBoundingClientRect();
|
|
435
|
+
bounds.setTo(
|
|
436
|
+
clientRect.left - parentRect.left,
|
|
437
|
+
clientRect.top - parentRect.top,
|
|
438
|
+
clientRect.width,
|
|
439
|
+
clientRect.height
|
|
440
|
+
);
|
|
419
441
|
const wc = this.windowConstraints;
|
|
420
442
|
if (wc.right) {
|
|
421
443
|
const windowBounds = wc.right === 'layout' ? layoutBounds : visualBounds;
|
|
@@ -426,7 +448,12 @@ export default class {
|
|
|
426
448
|
bounds.bottom = Math.min(bounds.bottom, windowBounds.height);
|
|
427
449
|
}
|
|
428
450
|
}
|
|
429
|
-
bounds.setTo(
|
|
451
|
+
bounds.setTo(
|
|
452
|
+
Math.round(bounds.x),
|
|
453
|
+
Math.round(bounds.y),
|
|
454
|
+
Math.round(bounds.width),
|
|
455
|
+
Math.round(bounds.height)
|
|
456
|
+
);
|
|
430
457
|
return bounds;
|
|
431
458
|
}
|
|
432
459
|
|
|
@@ -440,7 +467,7 @@ export default class {
|
|
|
440
467
|
const canvasBounds = canvas.getBoundingClientRect();
|
|
441
468
|
if (this.width < parentBounds.width && !this.incorrectOrientation) {
|
|
442
469
|
const currentEdge = canvasBounds.left - parentBounds.x;
|
|
443
|
-
let targetEdge =
|
|
470
|
+
let targetEdge = parentBounds.width / 2 - this.width / 2;
|
|
444
471
|
targetEdge = Math.max(targetEdge, 0);
|
|
445
472
|
const offset = targetEdge - currentEdge;
|
|
446
473
|
margin.left = Math.round(offset);
|
|
@@ -457,7 +484,7 @@ export default class {
|
|
|
457
484
|
const canvasBounds = canvas.getBoundingClientRect();
|
|
458
485
|
if (this.height < parentBounds.height && !this.incorrectOrientation) {
|
|
459
486
|
const currentEdge = canvasBounds.top - parentBounds.y;
|
|
460
|
-
let targetEdge =
|
|
487
|
+
let targetEdge = parentBounds.height / 2 - this.height / 2;
|
|
461
488
|
targetEdge = Math.max(targetEdge, 0);
|
|
462
489
|
const offset = targetEdge - currentEdge;
|
|
463
490
|
margin.top = Math.round(offset);
|
|
@@ -482,7 +509,10 @@ export default class {
|
|
|
482
509
|
reflowCanvas() {
|
|
483
510
|
if (!this.incorrectOrientation) {
|
|
484
511
|
this.width = Math.max(this.minWidth || 0, Math.min(this.maxWidth || this.width, this.width));
|
|
485
|
-
this.height = Math.max(
|
|
512
|
+
this.height = Math.max(
|
|
513
|
+
this.minHeight || 0,
|
|
514
|
+
Math.min(this.maxHeight || this.height, this.height)
|
|
515
|
+
);
|
|
486
516
|
}
|
|
487
517
|
this.resetCanvas();
|
|
488
518
|
if (!this.compatibility.noMargins) {
|
|
@@ -530,9 +560,9 @@ export default class {
|
|
|
530
560
|
const height = bounds.height;
|
|
531
561
|
let multiplier;
|
|
532
562
|
if (expanding) {
|
|
533
|
-
multiplier = Math.max(
|
|
563
|
+
multiplier = Math.max(height / this.game.height, width / this.game.width);
|
|
534
564
|
} else {
|
|
535
|
-
multiplier = Math.min(
|
|
565
|
+
multiplier = Math.min(height / this.game.height, width / this.game.width);
|
|
536
566
|
}
|
|
537
567
|
this.width = Math.round(this.game.width * multiplier);
|
|
538
568
|
this.height = Math.round(this.game.height * multiplier);
|
|
@@ -576,8 +606,15 @@ export default class {
|
|
|
576
606
|
}
|
|
577
607
|
if (this.compatibility.clickTrampoline === 'when-not-mouse') {
|
|
578
608
|
const input = this.game.input;
|
|
579
|
-
if (
|
|
580
|
-
input.activePointer
|
|
609
|
+
if (
|
|
610
|
+
input.activePointer &&
|
|
611
|
+
input.activePointer !== input.mousePointer &&
|
|
612
|
+
(allowTrampoline || allowTrampoline !== false)
|
|
613
|
+
) {
|
|
614
|
+
input.activePointer.addClickTrampoline('startFullScreen', this.startFullScreen, this, [
|
|
615
|
+
antialias,
|
|
616
|
+
false,
|
|
617
|
+
]);
|
|
581
618
|
return false;
|
|
582
619
|
}
|
|
583
620
|
}
|
|
@@ -698,7 +735,10 @@ export default class {
|
|
|
698
735
|
}
|
|
699
736
|
|
|
700
737
|
get boundingParent() {
|
|
701
|
-
if (
|
|
738
|
+
if (
|
|
739
|
+
this.parentIsWindow ||
|
|
740
|
+
(this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget)
|
|
741
|
+
) {
|
|
702
742
|
return null;
|
|
703
743
|
}
|
|
704
744
|
const parentNode = this.game.canvas && this.game.canvas.parentNode;
|
|
@@ -752,7 +792,12 @@ export default class {
|
|
|
752
792
|
}
|
|
753
793
|
|
|
754
794
|
get isFullScreen() {
|
|
755
|
-
return !!(
|
|
795
|
+
return !!(
|
|
796
|
+
document.fullscreenElement ||
|
|
797
|
+
document.webkitFullscreenElement ||
|
|
798
|
+
document.mozFullScreenElement ||
|
|
799
|
+
document.msFullscreenElement
|
|
800
|
+
);
|
|
756
801
|
}
|
|
757
802
|
|
|
758
803
|
get isPortrait() {
|
|
@@ -770,5 +815,4 @@ export default class {
|
|
|
770
815
|
get isGameLandscape() {
|
|
771
816
|
return this.width > this.height;
|
|
772
817
|
}
|
|
773
|
-
|
|
774
818
|
}
|
package/src/phaser/core/scene.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 Scene {
|
|
8
7
|
constructor() {
|
|
9
8
|
this.game = null;
|
|
10
9
|
this.key = '';
|
|
@@ -37,5 +36,4 @@ export default class {
|
|
|
37
36
|
shutdown() {
|
|
38
37
|
// inherit
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
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 Scene from './scene';
|
|
7
|
-
|
|
8
|
-
export default class {
|
|
6
|
+
import { Scene } from './scene';
|
|
9
7
|
|
|
8
|
+
export class SceneManager {
|
|
10
9
|
constructor(game, pendingState) {
|
|
11
10
|
this.game = game;
|
|
12
11
|
this.states = {};
|
|
@@ -141,7 +140,12 @@ export default class {
|
|
|
141
140
|
|
|
142
141
|
checkState(key) {
|
|
143
142
|
if (this.states[key]) {
|
|
144
|
-
if (
|
|
143
|
+
if (
|
|
144
|
+
this.states[key].preload ||
|
|
145
|
+
this.states[key].create ||
|
|
146
|
+
this.states[key].update ||
|
|
147
|
+
this.states[key].render
|
|
148
|
+
) {
|
|
145
149
|
return true;
|
|
146
150
|
}
|
|
147
151
|
return false;
|
|
@@ -235,5 +239,4 @@ export default class {
|
|
|
235
239
|
get created() {
|
|
236
240
|
return this._created;
|
|
237
241
|
}
|
|
238
|
-
|
|
239
242
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module core/signal
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @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
6
|
*/
|
|
6
|
-
import SignalBinding from
|
|
7
|
-
|
|
8
|
-
export default class {
|
|
7
|
+
import { SignalBinding } from './signal_binding';
|
|
9
8
|
|
|
9
|
+
export class Signal {
|
|
10
10
|
constructor() {
|
|
11
11
|
this._bindings = null;
|
|
12
12
|
this._prevParams = null;
|
|
@@ -18,7 +18,12 @@ export default class {
|
|
|
18
18
|
|
|
19
19
|
validateListener(listener, fnName) {
|
|
20
20
|
if (typeof listener !== 'function') {
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error(
|
|
22
|
+
'Signal: listener is a required param of {fn}() and should be a Function.'.replace(
|
|
23
|
+
'{fn}',
|
|
24
|
+
fnName
|
|
25
|
+
)
|
|
26
|
+
);
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
|
|
@@ -28,7 +33,13 @@ export default class {
|
|
|
28
33
|
if (prevIndex !== -1) {
|
|
29
34
|
binding = this._bindings[prevIndex];
|
|
30
35
|
if (binding.isOnce() !== isOnce) {
|
|
31
|
-
throw new Error(
|
|
36
|
+
throw new Error(
|
|
37
|
+
'You cannot add' +
|
|
38
|
+
(isOnce ? '' : 'Once') +
|
|
39
|
+
'() then add' +
|
|
40
|
+
(!isOnce ? '' : 'Once') +
|
|
41
|
+
'() the same listener without removing the relationship first.'
|
|
42
|
+
);
|
|
32
43
|
}
|
|
33
44
|
} else {
|
|
34
45
|
binding = new SignalBinding(this, listener, isOnce, listenerContext, priority, args);
|
|
@@ -48,8 +59,7 @@ export default class {
|
|
|
48
59
|
let n = this._bindings.length;
|
|
49
60
|
do {
|
|
50
61
|
n -= 1;
|
|
51
|
-
}
|
|
52
|
-
while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
|
|
62
|
+
} while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
|
|
53
63
|
this._bindings.splice(n + 1, 0, binding);
|
|
54
64
|
}
|
|
55
65
|
|
|
@@ -144,8 +154,7 @@ export default class {
|
|
|
144
154
|
// reverse loop since listeners with higher priority will be added at the end of the list
|
|
145
155
|
do {
|
|
146
156
|
n -= 1;
|
|
147
|
-
}
|
|
148
|
-
while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
|
|
157
|
+
} while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
forget() {
|
|
@@ -171,5 +180,4 @@ export default class {
|
|
|
171
180
|
}
|
|
172
181
|
return this._boundDispatch;
|
|
173
182
|
}
|
|
174
|
-
|
|
175
183
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
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
6
|
|
|
7
|
-
export
|
|
8
|
-
|
|
7
|
+
export class SignalBinding {
|
|
9
8
|
constructor(signal, listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
|
|
10
9
|
this._signal = signal;
|
|
11
10
|
this._listener = listener;
|
|
@@ -33,7 +32,6 @@ export default class {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
return handlerReturn;
|
|
36
|
-
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
detach() {
|
|
@@ -41,7 +39,7 @@ export default class {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
isBound() {
|
|
44
|
-
return
|
|
42
|
+
return !!this._signal && !!this._listener;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
isOnce() {
|
|
@@ -63,7 +61,14 @@ export default class {
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
toString() {
|
|
66
|
-
return
|
|
64
|
+
return (
|
|
65
|
+
'[SignalBinding isOnce:' +
|
|
66
|
+
this._isOnce +
|
|
67
|
+
', isBound:' +
|
|
68
|
+
this.isBound() +
|
|
69
|
+
', active:' +
|
|
70
|
+
this.active +
|
|
71
|
+
']'
|
|
72
|
+
);
|
|
67
73
|
}
|
|
68
|
-
|
|
69
74
|
}
|
package/src/phaser/core/sound.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
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
|
-
|
|
8
|
-
export default class {
|
|
6
|
+
import { Signal } from './signal';
|
|
9
7
|
|
|
8
|
+
export class Sound {
|
|
10
9
|
constructor(game, key, volume = 1, loop = false, connect = null) {
|
|
11
10
|
// TODO
|
|
12
11
|
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
|
|
@@ -179,8 +178,12 @@ export default class {
|
|
|
179
178
|
}
|
|
180
179
|
|
|
181
180
|
play(marker, position, volume, loop, forceRestart) {
|
|
182
|
-
if (marker === undefined || marker === false || marker === null) {
|
|
183
|
-
|
|
181
|
+
if (marker === undefined || marker === false || marker === null) {
|
|
182
|
+
marker = '';
|
|
183
|
+
}
|
|
184
|
+
if (forceRestart === undefined) {
|
|
185
|
+
forceRestart = true;
|
|
186
|
+
}
|
|
184
187
|
|
|
185
188
|
if (this.isPlaying && !this.allowMultiple && !forceRestart && !this.override) {
|
|
186
189
|
// Use Restart instead
|
|
@@ -231,8 +234,12 @@ export default class {
|
|
|
231
234
|
}
|
|
232
235
|
} else {
|
|
233
236
|
position = position || 0;
|
|
234
|
-
if (volume === undefined) {
|
|
235
|
-
|
|
237
|
+
if (volume === undefined) {
|
|
238
|
+
volume = this._volume;
|
|
239
|
+
}
|
|
240
|
+
if (loop === undefined) {
|
|
241
|
+
loop = this.loop;
|
|
242
|
+
}
|
|
236
243
|
this.position = Math.max(0, position);
|
|
237
244
|
this.volume = volume;
|
|
238
245
|
this.loop = loop;
|
|
@@ -280,7 +287,10 @@ export default class {
|
|
|
280
287
|
this.onPlay.dispatch(this);
|
|
281
288
|
} else {
|
|
282
289
|
this.pendingPlayback = true;
|
|
283
|
-
if (
|
|
290
|
+
if (
|
|
291
|
+
this.game.cache.getSound(this.key) &&
|
|
292
|
+
this.game.cache.getSound(this.key).isDecoding === false
|
|
293
|
+
) {
|
|
284
294
|
this.game.sound.decode(this.key, this);
|
|
285
295
|
}
|
|
286
296
|
}
|
|
@@ -331,7 +341,7 @@ export default class {
|
|
|
331
341
|
resume() {
|
|
332
342
|
if (this.paused && this._sound) {
|
|
333
343
|
if (!this.game.sound.noAudio) {
|
|
334
|
-
const p = Math.max(0, this.position +
|
|
344
|
+
const p = Math.max(0, this.position + this.pausedPosition / 1000);
|
|
335
345
|
this._sound = this.context.createBufferSource();
|
|
336
346
|
this._sound.buffer = this._buffer;
|
|
337
347
|
if (this.externalNode) {
|
|
@@ -345,7 +355,7 @@ export default class {
|
|
|
345
355
|
if (!this.loop && this.currentMarker === '') {
|
|
346
356
|
this._sound.onended = this.onEndedHandler.bind(this);
|
|
347
357
|
}
|
|
348
|
-
const duration = this.duration -
|
|
358
|
+
const duration = this.duration - this.pausedPosition / 1000;
|
|
349
359
|
if (this._sound.start === undefined) {
|
|
350
360
|
this._sound.noteGrainOn(0, p, duration);
|
|
351
361
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=457099
|
|
@@ -357,7 +367,7 @@ export default class {
|
|
|
357
367
|
}
|
|
358
368
|
this.isPlaying = true;
|
|
359
369
|
this.paused = false;
|
|
360
|
-
this.startTime +=
|
|
370
|
+
this.startTime += this.game.time.time - this.pausedTime;
|
|
361
371
|
this.onResume.dispatch(this);
|
|
362
372
|
}
|
|
363
373
|
}
|
|
@@ -441,7 +451,7 @@ export default class {
|
|
|
441
451
|
}
|
|
442
452
|
|
|
443
453
|
get mute() {
|
|
444
|
-
return
|
|
454
|
+
return this._muted || this.game.sound.mute;
|
|
445
455
|
}
|
|
446
456
|
|
|
447
457
|
set mute(value) {
|
|
@@ -479,5 +489,4 @@ export default class {
|
|
|
479
489
|
this.gainNode.gain.value = value;
|
|
480
490
|
}
|
|
481
491
|
}
|
|
482
|
-
|
|
483
492
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
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 ArraySet from './array_set';
|
|
7
|
-
import Signal from
|
|
8
|
-
import Sound from './sound';
|
|
9
|
-
import SoundSprite from './sound_sprite';
|
|
10
|
-
|
|
11
|
-
export default class {
|
|
6
|
+
import { ArraySet } from './array_set';
|
|
7
|
+
import { Signal } from './signal';
|
|
8
|
+
import { Sound } from './sound';
|
|
9
|
+
import { SoundSprite } from './sound_sprite';
|
|
12
10
|
|
|
11
|
+
export class SoundManager {
|
|
13
12
|
constructor(game) {
|
|
14
13
|
this.game = game;
|
|
15
14
|
this.onChange = new Signal();
|
|
@@ -56,11 +55,16 @@ export default class {
|
|
|
56
55
|
this.game.exceptionHandler(e);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
if (
|
|
58
|
+
if (
|
|
59
|
+
this.context === null ||
|
|
60
|
+
(this.context &&
|
|
61
|
+
this.context.createGain === undefined &&
|
|
62
|
+
this.context.createGainNode === undefined)
|
|
63
|
+
) {
|
|
60
64
|
this.noAudio = true;
|
|
61
65
|
return;
|
|
62
|
-
}
|
|
63
|
-
this.baseLatency = this.context.baseLatency ||
|
|
66
|
+
}
|
|
67
|
+
this.baseLatency = this.context.baseLatency || 256 / (this.context.sampleRate || 44100);
|
|
64
68
|
if (this.context.createGain === undefined) {
|
|
65
69
|
this.masterGain = this.context.createGainNode();
|
|
66
70
|
} else {
|
|
@@ -75,18 +79,27 @@ export default class {
|
|
|
75
79
|
this.addUnlockHandlers();
|
|
76
80
|
}
|
|
77
81
|
this.context.addEventListener('statechange', () => {
|
|
78
|
-
this.onChange.dispatch('onContextStateChange', {
|
|
79
|
-
|
|
82
|
+
this.onChange.dispatch('onContextStateChange', {
|
|
83
|
+
state: this.context.state,
|
|
84
|
+
isLocked: this.isLocked,
|
|
85
|
+
});
|
|
86
|
+
if (
|
|
87
|
+
!this.isLocked &&
|
|
88
|
+
(this.context.state === 'suspended' || this.context.state === 'interrupted')
|
|
89
|
+
) {
|
|
80
90
|
this.addUnlockHandlers();
|
|
81
91
|
} else if (this.isLocked && this.context.state === 'running') {
|
|
82
92
|
this.removeUnlockHandlers();
|
|
83
|
-
}
|
|
93
|
+
}
|
|
84
94
|
});
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
addUnlockHandlers() {
|
|
88
98
|
this.isLocked = true;
|
|
89
|
-
this.onChange.dispatch('addUnlockHandlers', {
|
|
99
|
+
this.onChange.dispatch('addUnlockHandlers', {
|
|
100
|
+
state: this.context.state,
|
|
101
|
+
isLocked: this.isLocked,
|
|
102
|
+
});
|
|
90
103
|
document.body.addEventListener('touchstart', this.onUnlockEventBinded, false);
|
|
91
104
|
document.body.addEventListener('touchend', this.onUnlockEventBinded, false);
|
|
92
105
|
document.body.addEventListener('click', this.onUnlockEventBinded, false);
|
|
@@ -95,7 +108,10 @@ export default class {
|
|
|
95
108
|
|
|
96
109
|
removeUnlockHandlers() {
|
|
97
110
|
this.isLocked = false;
|
|
98
|
-
this.onChange.dispatch('removeUnlockHandlers', {
|
|
111
|
+
this.onChange.dispatch('removeUnlockHandlers', {
|
|
112
|
+
state: this.context.state,
|
|
113
|
+
isLocked: this.isLocked,
|
|
114
|
+
});
|
|
99
115
|
document.body.removeEventListener('touchstart', this.onUnlockEventBinded);
|
|
100
116
|
document.body.removeEventListener('touchend', this.onUnlockEventBinded);
|
|
101
117
|
document.body.removeEventListener('click', this.onUnlockEventBinded);
|
|
@@ -105,19 +121,39 @@ export default class {
|
|
|
105
121
|
onUnlockEvent(event) {
|
|
106
122
|
const initialState = this.context.state;
|
|
107
123
|
if (initialState !== 'suspended' && initialState !== 'interrupted') {
|
|
108
|
-
this.onChange.dispatch('onUnlockResumeDenied', {
|
|
124
|
+
this.onChange.dispatch('onUnlockResumeDenied', {
|
|
125
|
+
state: initialState,
|
|
126
|
+
isLocked: this.isLocked,
|
|
127
|
+
event,
|
|
128
|
+
});
|
|
109
129
|
this.removeUnlockHandlers();
|
|
110
130
|
return;
|
|
111
131
|
}
|
|
112
|
-
this.onChange.dispatch('onContextResumeStart', {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}).catch((e) => {
|
|
117
|
-
this.onChange.dispatch('onContextResumeReject', { initialState, state: this.context.state, isLocked: this.isLocked, error: e });
|
|
118
|
-
this.removeUnlockHandlers();
|
|
119
|
-
this.game.exceptionHandler(e, { initialState, state: this.context.state });
|
|
132
|
+
this.onChange.dispatch('onContextResumeStart', {
|
|
133
|
+
state: initialState,
|
|
134
|
+
isLocked: this.isLocked,
|
|
135
|
+
event,
|
|
120
136
|
});
|
|
137
|
+
this.context
|
|
138
|
+
.resume()
|
|
139
|
+
.then(() => {
|
|
140
|
+
this.onChange.dispatch('onContextResumeResult', {
|
|
141
|
+
initialState,
|
|
142
|
+
state: this.context.state,
|
|
143
|
+
isLocked: this.isLocked,
|
|
144
|
+
});
|
|
145
|
+
this.removeUnlockHandlers();
|
|
146
|
+
})
|
|
147
|
+
.catch((e) => {
|
|
148
|
+
this.onChange.dispatch('onContextResumeReject', {
|
|
149
|
+
initialState,
|
|
150
|
+
state: this.context.state,
|
|
151
|
+
isLocked: this.isLocked,
|
|
152
|
+
error: e,
|
|
153
|
+
});
|
|
154
|
+
this.removeUnlockHandlers();
|
|
155
|
+
this.game.exceptionHandler(e, { initialState, state: this.context.state });
|
|
156
|
+
});
|
|
121
157
|
}
|
|
122
158
|
|
|
123
159
|
stopAll() {
|
|
@@ -158,7 +194,8 @@ export default class {
|
|
|
158
194
|
if (soundData) {
|
|
159
195
|
if (this.game.cache.isSoundDecoded(key) === false) {
|
|
160
196
|
this.game.cache.updateSound(key, 'isDecoding', true);
|
|
161
|
-
this.context
|
|
197
|
+
this.context
|
|
198
|
+
.decodeAudioData(soundData)
|
|
162
199
|
.then((buffer) => {
|
|
163
200
|
this.game.cache.decodedSound(key, buffer);
|
|
164
201
|
})
|
|
@@ -340,5 +377,4 @@ export default class {
|
|
|
340
377
|
}
|
|
341
378
|
}
|
|
342
379
|
}
|
|
343
|
-
|
|
344
380
|
}
|