@vpmedia/phaser 1.14.0 → 1.16.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 +3 -3
- package/package.json +6 -5
- package/src/index.js +15 -18
- package/src/phaser/core/animation.js +102 -6
- package/src/phaser/core/animation_manager.js +88 -10
- package/src/phaser/core/animation_parser.js +5 -20
- package/src/phaser/core/array_set.js +51 -5
- package/src/phaser/core/cache.js +291 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +5 -6
- package/src/phaser/core/device_util.js +3 -25
- package/src/phaser/core/dom.js +127 -29
- package/src/phaser/core/event_manager.js +128 -6
- package/src/phaser/core/factory.js +69 -34
- package/src/phaser/core/frame.js +43 -6
- package/src/phaser/core/frame_data.js +55 -5
- package/src/phaser/core/frame_util.js +7 -14
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +116 -17
- package/src/phaser/core/input_handler.js +242 -42
- package/src/phaser/core/input_mouse.js +68 -7
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +79 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +274 -101
- package/src/phaser/core/loader_parser.js +2 -14
- package/src/phaser/core/raf.js +16 -5
- package/src/phaser/core/scale_manager.js +204 -39
- package/src/phaser/core/scene.js +24 -5
- package/src/phaser/core/scene_manager.js +81 -11
- package/src/phaser/core/signal.js +88 -11
- package/src/phaser/core/signal_binding.js +35 -15
- package/src/phaser/core/sound.js +99 -10
- package/src/phaser/core/sound_manager.js +89 -13
- package/src/phaser/core/sound_sprite.js +20 -5
- package/src/phaser/core/stage.js +43 -7
- package/src/phaser/core/time.js +67 -5
- package/src/phaser/core/timer.js +107 -30
- package/src/phaser/core/timer_event.js +11 -6
- package/src/phaser/core/tween.js +124 -30
- package/src/phaser/core/tween_data.js +42 -18
- package/src/phaser/core/tween_easing.js +1 -39
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +92 -11
- package/src/phaser/display/button.js +64 -13
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -16
- package/src/phaser/display/canvas/masker.js +0 -8
- package/src/phaser/display/canvas/pool.js +0 -14
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -48
- package/src/phaser/display/canvas/util.js +0 -15
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +162 -27
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -9
- package/src/phaser/display/group.js +75 -10
- package/src/phaser/display/image.js +86 -10
- package/src/phaser/display/sprite_batch.js +3 -9
- package/src/phaser/display/sprite_util.js +3 -28
- package/src/phaser/display/text.js +332 -32
- package/src/phaser/display/webgl/abstract_filter.js +8 -7
- package/src/phaser/display/webgl/base_texture.js +20 -12
- package/src/phaser/display/webgl/blend_manager.js +14 -7
- package/src/phaser/display/webgl/earcut.js +4 -50
- package/src/phaser/display/webgl/earcut_node.js +6 -7
- package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
- package/src/phaser/display/webgl/filter_manager.js +25 -7
- package/src/phaser/display/webgl/filter_texture.js +21 -22
- package/src/phaser/display/webgl/graphics.js +5 -40
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -8
- package/src/phaser/display/webgl/render_texture.js +33 -21
- package/src/phaser/display/webgl/renderer.js +38 -11
- package/src/phaser/display/webgl/shader/complex.js +10 -6
- package/src/phaser/display/webgl/shader/fast.js +10 -6
- package/src/phaser/display/webgl/shader/normal.js +23 -32
- package/src/phaser/display/webgl/shader/primitive.js +10 -6
- package/src/phaser/display/webgl/shader/strip.js +10 -6
- package/src/phaser/display/webgl/shader_manager.js +18 -6
- package/src/phaser/display/webgl/sprite_batch.js +41 -8
- package/src/phaser/display/webgl/stencil_manager.js +28 -6
- package/src/phaser/display/webgl/texture.js +28 -15
- package/src/phaser/display/webgl/texture_util.js +0 -8
- package/src/phaser/display/webgl/util.js +0 -11
- package/src/phaser/geom/circle.js +123 -19
- package/src/phaser/geom/ellipse.js +39 -19
- package/src/phaser/geom/line.js +148 -17
- package/src/phaser/geom/matrix.js +73 -7
- package/src/phaser/geom/point.js +152 -7
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -7
- package/src/phaser/geom/rounded_rectangle.js +10 -7
- package/src/phaser/geom/util/circle.js +3 -16
- package/src/phaser/geom/util/ellipse.js +0 -8
- package/src/phaser/geom/util/line.js +5 -19
- package/src/phaser/geom/util/matrix.js +1 -10
- package/src/phaser/geom/util/point.js +0 -26
- package/src/phaser/geom/util/polygon.js +1 -8
- package/src/phaser/geom/util/rectangle.js +1 -23
- package/src/phaser/geom/util/rounded_rectangle.js +1 -8
- package/src/phaser/util/math.js +3 -43
- package/{types → typedefs}/global.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +106 -5
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +88 -1
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +5 -6
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +53 -7
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +348 -58
- package/types/phaser/core/cache.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +143 -40
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device.d.ts +2 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -10
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +122 -3
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +142 -15
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +74 -7
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +68 -26
- package/types/phaser/core/frame.d.ts.map +1 -1
- package/types/phaser/core/frame_data.d.ts +61 -9
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +10 -10
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -20
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +132 -21
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +258 -25
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +59 -12
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +49 -15
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +80 -4
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +52 -15
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +268 -23
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts +0 -4
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +17 -7
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +210 -15
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +21 -5
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +90 -10
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +95 -11
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +35 -6
- package/types/phaser/core/signal_binding.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +111 -14
- package/types/phaser/core/sound.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +94 -8
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/sound_sprite.d.ts +22 -8
- package/types/phaser/core/sound_sprite.d.ts.map +1 -1
- package/types/phaser/core/stage.d.ts +32 -3
- package/types/phaser/core/stage.d.ts.map +1 -1
- package/types/phaser/core/time.d.ts +73 -6
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +103 -2
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +11 -5
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +123 -3
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +42 -3
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -36
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +49 -2
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +9 -1
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +89 -12
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +68 -11
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +21 -5
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts +0 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts +0 -2
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -13
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +30 -3
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts +0 -5
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +0 -9
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +196 -9
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +142 -16
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +15 -1
- package/types/phaser/display/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +3 -3
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +68 -6
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +77 -15
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -4
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts +0 -5
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +373 -53
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/types/phaser/display/webgl/base_texture.d.ts +20 -1
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut.d.ts +0 -27
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_manager.d.ts +23 -7
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts +0 -12
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +12 -8
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts +0 -2
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +31 -4
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +42 -5
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +12 -2
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +12 -2
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +21 -1
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +12 -2
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +12 -2
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +20 -5
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +38 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture.d.ts +22 -1
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts +0 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -10
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +130 -10
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +42 -6
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -14
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +84 -12
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -19
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +45 -5
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +253 -21
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -2
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -10
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -7
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -10
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts +0 -3
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts +0 -20
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts +0 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts +0 -16
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -27
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
1
|
+
import { Game } from './game';
|
|
6
2
|
import { Scene } from './scene';
|
|
7
3
|
|
|
8
4
|
export class SceneManager {
|
|
5
|
+
/**
|
|
6
|
+
* TBD.
|
|
7
|
+
* @param {Game} game - TBD.
|
|
8
|
+
* @param pendingState
|
|
9
|
+
*/
|
|
9
10
|
constructor(game, pendingState) {
|
|
10
11
|
this.game = game;
|
|
11
12
|
this.states = {};
|
|
@@ -27,12 +28,21 @@ export class SceneManager {
|
|
|
27
28
|
this.onShutDownCallback = null;
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
/**
|
|
32
|
+
* TBD.
|
|
33
|
+
*/
|
|
30
34
|
boot() {
|
|
31
35
|
if (this._pendingState !== null && typeof this._pendingState !== 'string') {
|
|
32
36
|
this.add('default', this._pendingState, true);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* TBD.
|
|
42
|
+
* @param {string} key - TBD.
|
|
43
|
+
* @param state
|
|
44
|
+
* @param autoStart
|
|
45
|
+
*/
|
|
36
46
|
add(key, state, autoStart = false) {
|
|
37
47
|
let newState = null;
|
|
38
48
|
if (state instanceof Scene) {
|
|
@@ -54,6 +64,10 @@ export class SceneManager {
|
|
|
54
64
|
return newState;
|
|
55
65
|
}
|
|
56
66
|
|
|
67
|
+
/**
|
|
68
|
+
* TBD.
|
|
69
|
+
* @param {string} key - TBD.
|
|
70
|
+
*/
|
|
57
71
|
remove(key) {
|
|
58
72
|
if (this.current === key) {
|
|
59
73
|
this.callbackContext = null;
|
|
@@ -68,6 +82,13 @@ export class SceneManager {
|
|
|
68
82
|
delete this.states[key];
|
|
69
83
|
}
|
|
70
84
|
|
|
85
|
+
/**
|
|
86
|
+
* TBD.
|
|
87
|
+
* @param {string} key - TBD.
|
|
88
|
+
* @param clearWorld
|
|
89
|
+
* @param clearCache
|
|
90
|
+
* @param {...any} args
|
|
91
|
+
*/
|
|
71
92
|
start(key, clearWorld = true, clearCache = false, ...args) {
|
|
72
93
|
if (this.checkState(key)) {
|
|
73
94
|
// Place the state in the queue. It will be started the next time the game loop begins.
|
|
@@ -80,6 +101,12 @@ export class SceneManager {
|
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
103
|
|
|
104
|
+
/**
|
|
105
|
+
* TBD.
|
|
106
|
+
* @param clearWorld
|
|
107
|
+
* @param clearCache
|
|
108
|
+
* @param {...any} args
|
|
109
|
+
*/
|
|
83
110
|
restart(clearWorld = true, clearCache = false, ...args) {
|
|
84
111
|
this._pendingState = this.current;
|
|
85
112
|
this._clearWorld = clearWorld;
|
|
@@ -89,6 +116,9 @@ export class SceneManager {
|
|
|
89
116
|
}
|
|
90
117
|
}
|
|
91
118
|
|
|
119
|
+
/**
|
|
120
|
+
* TBD.
|
|
121
|
+
*/
|
|
92
122
|
preUpdate() {
|
|
93
123
|
if (this._pendingState && this.game.isBooted) {
|
|
94
124
|
// var previousStateKey = this.current;
|
|
@@ -120,6 +150,9 @@ export class SceneManager {
|
|
|
120
150
|
}
|
|
121
151
|
}
|
|
122
152
|
|
|
153
|
+
/**
|
|
154
|
+
* TBD.
|
|
155
|
+
*/
|
|
123
156
|
clearCurrentState() {
|
|
124
157
|
if (this.current) {
|
|
125
158
|
if (this.onShutDownCallback) {
|
|
@@ -138,14 +171,13 @@ export class SceneManager {
|
|
|
138
171
|
}
|
|
139
172
|
}
|
|
140
173
|
|
|
174
|
+
/**
|
|
175
|
+
* TBD.
|
|
176
|
+
* @param {string} key - TBD.
|
|
177
|
+
*/
|
|
141
178
|
checkState(key) {
|
|
142
179
|
if (this.states[key]) {
|
|
143
|
-
if (
|
|
144
|
-
this.states[key].preload ||
|
|
145
|
-
this.states[key].create ||
|
|
146
|
-
this.states[key].update ||
|
|
147
|
-
this.states[key].render
|
|
148
|
-
) {
|
|
180
|
+
if (this.states[key].preload || this.states[key].create || this.states[key].update || this.states[key].render) {
|
|
149
181
|
return true;
|
|
150
182
|
}
|
|
151
183
|
return false;
|
|
@@ -153,17 +185,29 @@ export class SceneManager {
|
|
|
153
185
|
return false;
|
|
154
186
|
}
|
|
155
187
|
|
|
188
|
+
/**
|
|
189
|
+
* TBD.
|
|
190
|
+
* @param {string} key - TBD.
|
|
191
|
+
*/
|
|
156
192
|
link(key) {
|
|
157
193
|
this.states[key].game = this.game;
|
|
158
194
|
this.states[key].key = key;
|
|
159
195
|
}
|
|
160
196
|
|
|
197
|
+
/**
|
|
198
|
+
* TBD.
|
|
199
|
+
* @param {string} key - TBD.
|
|
200
|
+
*/
|
|
161
201
|
unlink(key) {
|
|
162
202
|
if (this.states[key]) {
|
|
163
203
|
this.states[key].game = null;
|
|
164
204
|
}
|
|
165
205
|
}
|
|
166
206
|
|
|
207
|
+
/**
|
|
208
|
+
* TBD.
|
|
209
|
+
* @param {string} key - TBD.
|
|
210
|
+
*/
|
|
167
211
|
setCurrentState(key) {
|
|
168
212
|
this.callbackContext = this.states[key];
|
|
169
213
|
this.link(key);
|
|
@@ -184,10 +228,16 @@ export class SceneManager {
|
|
|
184
228
|
this.game.isKickStart = true;
|
|
185
229
|
}
|
|
186
230
|
|
|
231
|
+
/**
|
|
232
|
+
* TBD.
|
|
233
|
+
*/
|
|
187
234
|
getCurrentState() {
|
|
188
235
|
return this.states[this.current];
|
|
189
236
|
}
|
|
190
237
|
|
|
238
|
+
/**
|
|
239
|
+
* TBD.
|
|
240
|
+
*/
|
|
191
241
|
loadComplete() {
|
|
192
242
|
if (this._created === false && this.onCreateCallback) {
|
|
193
243
|
this._created = true;
|
|
@@ -197,24 +247,38 @@ export class SceneManager {
|
|
|
197
247
|
}
|
|
198
248
|
}
|
|
199
249
|
|
|
250
|
+
/**
|
|
251
|
+
* TBD.
|
|
252
|
+
*/
|
|
200
253
|
update() {
|
|
201
254
|
if (this._created && this.onUpdateCallback) {
|
|
202
255
|
this.onUpdateCallback.call(this.callbackContext, this.game);
|
|
203
256
|
}
|
|
204
257
|
}
|
|
205
258
|
|
|
259
|
+
/**
|
|
260
|
+
* TBD.
|
|
261
|
+
*/
|
|
206
262
|
pauseUpdate() {
|
|
207
263
|
if (this._created && this.onPauseUpdateCallback) {
|
|
208
264
|
this.onPauseUpdateCallback.call(this.callbackContext, this.game);
|
|
209
265
|
}
|
|
210
266
|
}
|
|
211
267
|
|
|
268
|
+
/**
|
|
269
|
+
* TBD.
|
|
270
|
+
* @param {number} width - TBD.
|
|
271
|
+
* @param {number} height - TBD.
|
|
272
|
+
*/
|
|
212
273
|
resize(width, height) {
|
|
213
274
|
if (this.onResizeCallback) {
|
|
214
275
|
this.onResizeCallback.call(this.callbackContext, width, height);
|
|
215
276
|
}
|
|
216
277
|
}
|
|
217
278
|
|
|
279
|
+
/**
|
|
280
|
+
* TBD.
|
|
281
|
+
*/
|
|
218
282
|
destroy() {
|
|
219
283
|
this._clearWorld = true;
|
|
220
284
|
this._clearCache = true;
|
|
@@ -232,10 +296,16 @@ export class SceneManager {
|
|
|
232
296
|
this.current = '';
|
|
233
297
|
}
|
|
234
298
|
|
|
299
|
+
/**
|
|
300
|
+
* TBD.
|
|
301
|
+
*/
|
|
235
302
|
dummy() {
|
|
236
303
|
// pass
|
|
237
304
|
}
|
|
238
305
|
|
|
306
|
+
/**
|
|
307
|
+
* TBD.
|
|
308
|
+
*/
|
|
239
309
|
get created() {
|
|
240
310
|
return this._created;
|
|
241
311
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* @module core/signal
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
|
-
import { SignalBinding } from './signal_binding';
|
|
1
|
+
import { SignalBinding } from './signal_binding';
|
|
8
2
|
|
|
9
3
|
export class Signal {
|
|
4
|
+
/**
|
|
5
|
+
* TBD.
|
|
6
|
+
*/
|
|
10
7
|
constructor() {
|
|
11
8
|
this._bindings = null;
|
|
12
9
|
this._prevParams = null;
|
|
@@ -16,17 +13,30 @@ export class Signal {
|
|
|
16
13
|
this._boundDispatch = false;
|
|
17
14
|
}
|
|
18
15
|
|
|
16
|
+
/**
|
|
17
|
+
* TBD.
|
|
18
|
+
* @param {Function} listener - TBD.
|
|
19
|
+
* @param {string} fnName - TBD.
|
|
20
|
+
* @throws Error.
|
|
21
|
+
*/
|
|
19
22
|
validateListener(listener, fnName) {
|
|
20
23
|
if (typeof listener !== 'function') {
|
|
21
24
|
throw new Error(
|
|
22
|
-
'Signal: listener is a required param of {fn}() and should be a Function.'.replace(
|
|
23
|
-
'{fn}',
|
|
24
|
-
fnName
|
|
25
|
-
)
|
|
25
|
+
'Signal: listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* TBD.
|
|
32
|
+
* @param {Function} listener - TBD.
|
|
33
|
+
* @param {boolean} isOnce - TBD.
|
|
34
|
+
* @param {object} listenerContext - TBD.
|
|
35
|
+
* @param {number} priority - TBD.
|
|
36
|
+
* @param {...any} args - TBD.
|
|
37
|
+
* @returns {SignalBinding} TBD.
|
|
38
|
+
* @throws Error.
|
|
39
|
+
*/
|
|
30
40
|
_registerListener(listener, isOnce, listenerContext, priority, args) {
|
|
31
41
|
const prevIndex = this._indexOfListener(listener, listenerContext);
|
|
32
42
|
let binding;
|
|
@@ -51,6 +61,10 @@ export class Signal {
|
|
|
51
61
|
return binding;
|
|
52
62
|
}
|
|
53
63
|
|
|
64
|
+
/**
|
|
65
|
+
* TBD.
|
|
66
|
+
* @param {SignalBinding} binding - TBD.
|
|
67
|
+
*/
|
|
54
68
|
_addBinding(binding) {
|
|
55
69
|
if (!this._bindings) {
|
|
56
70
|
this._bindings = [];
|
|
@@ -63,6 +77,12 @@ export class Signal {
|
|
|
63
77
|
this._bindings.splice(n + 1, 0, binding);
|
|
64
78
|
}
|
|
65
79
|
|
|
80
|
+
/**
|
|
81
|
+
* TBD.
|
|
82
|
+
* @param {Function} listener - TBD.
|
|
83
|
+
* @param {object} context - TBD.
|
|
84
|
+
* @returns {number} TBD.
|
|
85
|
+
*/
|
|
66
86
|
_indexOfListener(listener, context = null) {
|
|
67
87
|
if (!this._bindings) {
|
|
68
88
|
return -1;
|
|
@@ -79,20 +99,48 @@ export class Signal {
|
|
|
79
99
|
return -1;
|
|
80
100
|
}
|
|
81
101
|
|
|
102
|
+
/**
|
|
103
|
+
* TBD.
|
|
104
|
+
* @param {Function} listener - TBD.
|
|
105
|
+
* @param {object} context - TBD.
|
|
106
|
+
* @returns {boolean} TBD.
|
|
107
|
+
*/
|
|
82
108
|
has(listener, context) {
|
|
83
109
|
return this._indexOfListener(listener, context) !== -1;
|
|
84
110
|
}
|
|
85
111
|
|
|
112
|
+
/**
|
|
113
|
+
* TBD.
|
|
114
|
+
* @param {Function} listener - TBD.
|
|
115
|
+
* @param {object} listenerContext - TBD.
|
|
116
|
+
* @param {number} priority - TBD.
|
|
117
|
+
* @param {...any} args - TBD.
|
|
118
|
+
* @returns {SignalBinding} TBD.
|
|
119
|
+
*/
|
|
86
120
|
add(listener, listenerContext, priority, ...args) {
|
|
87
121
|
this.validateListener(listener, 'add');
|
|
88
122
|
return this._registerListener(listener, false, listenerContext, priority, args);
|
|
89
123
|
}
|
|
90
124
|
|
|
125
|
+
/**
|
|
126
|
+
* TBD.
|
|
127
|
+
* @param {Function} listener - TBD.
|
|
128
|
+
* @param {object} listenerContext - TBD.
|
|
129
|
+
* @param {number} priority - TBD.
|
|
130
|
+
* @param {...any} args - TBD.
|
|
131
|
+
* @returns {SignalBinding} TBD.
|
|
132
|
+
*/
|
|
91
133
|
addOnce(listener, listenerContext, priority, ...args) {
|
|
92
134
|
this.validateListener(listener, 'addOnce');
|
|
93
135
|
return this._registerListener(listener, true, listenerContext, priority, args);
|
|
94
136
|
}
|
|
95
137
|
|
|
138
|
+
/**
|
|
139
|
+
* TBD.
|
|
140
|
+
* @param {Function} listener - TBD.
|
|
141
|
+
* @param {object} context - TBD.
|
|
142
|
+
* @returns {Function} TBD.
|
|
143
|
+
*/
|
|
96
144
|
remove(listener, context) {
|
|
97
145
|
this.validateListener(listener, 'remove');
|
|
98
146
|
const i = this._indexOfListener(listener, context);
|
|
@@ -104,6 +152,10 @@ export class Signal {
|
|
|
104
152
|
return listener;
|
|
105
153
|
}
|
|
106
154
|
|
|
155
|
+
/**
|
|
156
|
+
* TBD.
|
|
157
|
+
* @param {object} context - TBD.
|
|
158
|
+
*/
|
|
107
159
|
removeAll(context = null) {
|
|
108
160
|
if (!this._bindings) {
|
|
109
161
|
return;
|
|
@@ -125,14 +177,25 @@ export class Signal {
|
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
179
|
|
|
180
|
+
/**
|
|
181
|
+
* TBD.
|
|
182
|
+
* @returns {number} TBD.
|
|
183
|
+
*/
|
|
128
184
|
getNumListeners() {
|
|
129
185
|
return this._bindings ? this._bindings.length : 0;
|
|
130
186
|
}
|
|
131
187
|
|
|
188
|
+
/**
|
|
189
|
+
* TBD.
|
|
190
|
+
*/
|
|
132
191
|
halt() {
|
|
133
192
|
this._shouldPropagate = false;
|
|
134
193
|
}
|
|
135
194
|
|
|
195
|
+
/**
|
|
196
|
+
* TBD.
|
|
197
|
+
* @param {...any} args - TBD.
|
|
198
|
+
*/
|
|
136
199
|
dispatch(...args) {
|
|
137
200
|
if (!this.active || !this._bindings) {
|
|
138
201
|
return;
|
|
@@ -157,22 +220,36 @@ export class Signal {
|
|
|
157
220
|
} while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
|
|
158
221
|
}
|
|
159
222
|
|
|
223
|
+
/**
|
|
224
|
+
* TBD.
|
|
225
|
+
*/
|
|
160
226
|
forget() {
|
|
161
227
|
if (this._prevParams) {
|
|
162
228
|
this._prevParams = null;
|
|
163
229
|
}
|
|
164
230
|
}
|
|
165
231
|
|
|
232
|
+
/**
|
|
233
|
+
* TBD.
|
|
234
|
+
*/
|
|
166
235
|
dispose() {
|
|
167
236
|
this.removeAll();
|
|
168
237
|
this.forget();
|
|
169
238
|
this._bindings = null;
|
|
170
239
|
}
|
|
171
240
|
|
|
241
|
+
/**
|
|
242
|
+
* TBD.
|
|
243
|
+
* @returns {string} TBD.
|
|
244
|
+
*/
|
|
172
245
|
toString() {
|
|
173
246
|
return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']';
|
|
174
247
|
}
|
|
175
248
|
|
|
249
|
+
/**
|
|
250
|
+
* TBD.
|
|
251
|
+
* @returns {boolean} TBD.
|
|
252
|
+
*/
|
|
176
253
|
get boundDispatch() {
|
|
177
254
|
const _this = this;
|
|
178
255
|
if (!this._boundDispatch) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
export class SignalBinding {
|
|
2
|
+
/**
|
|
3
|
+
* TBD.
|
|
4
|
+
* @param signal
|
|
5
|
+
* @param listener
|
|
6
|
+
* @param isOnce
|
|
7
|
+
* @param listenerContext
|
|
8
|
+
* @param priority
|
|
9
|
+
* @param args - TBD.
|
|
10
|
+
*/
|
|
8
11
|
constructor(signal, listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
|
|
9
12
|
this._signal = signal;
|
|
10
13
|
this._listener = listener;
|
|
@@ -17,6 +20,10 @@ export class SignalBinding {
|
|
|
17
20
|
this.params = null;
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
/**
|
|
24
|
+
* TBD.
|
|
25
|
+
* @param paramsArr
|
|
26
|
+
*/
|
|
20
27
|
execute(paramsArr) {
|
|
21
28
|
let handlerReturn;
|
|
22
29
|
let params;
|
|
@@ -34,41 +41,54 @@ export class SignalBinding {
|
|
|
34
41
|
return handlerReturn;
|
|
35
42
|
}
|
|
36
43
|
|
|
44
|
+
/**
|
|
45
|
+
* TBD.
|
|
46
|
+
*/
|
|
37
47
|
detach() {
|
|
38
48
|
return this.isBound() ? this._signal.remove(this._listener, this.context) : null;
|
|
39
49
|
}
|
|
40
50
|
|
|
51
|
+
/**
|
|
52
|
+
* TBD.
|
|
53
|
+
*/
|
|
41
54
|
isBound() {
|
|
42
55
|
return !!this._signal && !!this._listener;
|
|
43
56
|
}
|
|
44
57
|
|
|
58
|
+
/**
|
|
59
|
+
* TBD.
|
|
60
|
+
*/
|
|
45
61
|
isOnce() {
|
|
46
62
|
return this._isOnce;
|
|
47
63
|
}
|
|
48
64
|
|
|
65
|
+
/**
|
|
66
|
+
* TBD.
|
|
67
|
+
*/
|
|
49
68
|
getListener() {
|
|
50
69
|
return this._listener;
|
|
51
70
|
}
|
|
52
71
|
|
|
72
|
+
/**
|
|
73
|
+
* TBD.
|
|
74
|
+
*/
|
|
53
75
|
getSignal() {
|
|
54
76
|
return this._signal;
|
|
55
77
|
}
|
|
56
78
|
|
|
79
|
+
/**
|
|
80
|
+
* TBD.
|
|
81
|
+
*/
|
|
57
82
|
_destroy() {
|
|
58
83
|
delete this._signal;
|
|
59
84
|
delete this._listener;
|
|
60
85
|
delete this.context;
|
|
61
86
|
}
|
|
62
87
|
|
|
88
|
+
/**
|
|
89
|
+
* TBD.
|
|
90
|
+
*/
|
|
63
91
|
toString() {
|
|
64
|
-
return (
|
|
65
|
-
'[SignalBinding isOnce:' +
|
|
66
|
-
this._isOnce +
|
|
67
|
-
', isBound:' +
|
|
68
|
-
this.isBound() +
|
|
69
|
-
', active:' +
|
|
70
|
-
this.active +
|
|
71
|
-
']'
|
|
72
|
-
);
|
|
92
|
+
return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']';
|
|
73
93
|
}
|
|
74
94
|
}
|