@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
package/src/phaser/core/game.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module core/game
|
|
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
1
|
import { CanvasRenderer } from '../display/canvas/renderer';
|
|
8
2
|
import { WebGLRenderer } from '../display/webgl/renderer';
|
|
9
|
-
import { Signal } from
|
|
3
|
+
import { Signal } from './signal';
|
|
10
4
|
import { Loader } from './loader';
|
|
11
5
|
import { Cache } from './cache';
|
|
12
6
|
import { Input } from './input';
|
|
@@ -25,6 +19,10 @@ import { create, removeFromDOM, addToDOM, setTouchAction } from '../display/canv
|
|
|
25
19
|
import { initialize, checkOS } from './device_util';
|
|
26
20
|
|
|
27
21
|
export class Game {
|
|
22
|
+
/**
|
|
23
|
+
* TBD.
|
|
24
|
+
* @param {object} gameConfig - TBD.
|
|
25
|
+
*/
|
|
28
26
|
constructor(gameConfig = {}) {
|
|
29
27
|
if (!window.PhaserRegistry) {
|
|
30
28
|
window.PhaserRegistry = {};
|
|
@@ -72,6 +70,9 @@ export class Game {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
73
|
+
/**
|
|
74
|
+
* TBD.
|
|
75
|
+
*/
|
|
75
76
|
boot() {
|
|
76
77
|
if (this.isBooted) {
|
|
77
78
|
return;
|
|
@@ -105,6 +106,9 @@ export class Game {
|
|
|
105
106
|
this.onBoot.dispatch(this);
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* TBD.
|
|
111
|
+
*/
|
|
108
112
|
initRenderer() {
|
|
109
113
|
if (this.config.canvas) {
|
|
110
114
|
this.canvas = this.config.canvas;
|
|
@@ -165,6 +169,12 @@ export class Game {
|
|
|
165
169
|
setTouchAction(this.canvas);
|
|
166
170
|
}
|
|
167
171
|
|
|
172
|
+
/**
|
|
173
|
+
* TBD.
|
|
174
|
+
* @param {object} config - TBD.
|
|
175
|
+
* @param {string} key - TBD.
|
|
176
|
+
* @param {*} defaultValue - TBD.
|
|
177
|
+
*/
|
|
168
178
|
parseConfigElement(config, key, defaultValue) {
|
|
169
179
|
if (config[key] !== undefined) {
|
|
170
180
|
this.config[key] = config[key];
|
|
@@ -173,6 +183,10 @@ export class Game {
|
|
|
173
183
|
}
|
|
174
184
|
}
|
|
175
185
|
|
|
186
|
+
/**
|
|
187
|
+
* TBD.
|
|
188
|
+
* @param {object} config - TBD.
|
|
189
|
+
*/
|
|
176
190
|
parseConfig(config) {
|
|
177
191
|
this.parseConfigElement(config, 'width', 800);
|
|
178
192
|
this.parseConfigElement(config, 'height', 600);
|
|
@@ -205,6 +219,10 @@ export class Game {
|
|
|
205
219
|
this.state = new SceneManager(this, state);
|
|
206
220
|
}
|
|
207
221
|
|
|
222
|
+
/**
|
|
223
|
+
* TBD.
|
|
224
|
+
* @param {Event} event - TBD.
|
|
225
|
+
*/
|
|
208
226
|
contextLost(event) {
|
|
209
227
|
event.preventDefault();
|
|
210
228
|
if (this.renderer) {
|
|
@@ -212,6 +230,9 @@ export class Game {
|
|
|
212
230
|
}
|
|
213
231
|
}
|
|
214
232
|
|
|
233
|
+
/**
|
|
234
|
+
* TBD.
|
|
235
|
+
*/
|
|
215
236
|
contextRestored() {
|
|
216
237
|
this.renderer.initContext();
|
|
217
238
|
// this.cache.clearGLTextures();
|
|
@@ -220,6 +241,10 @@ export class Game {
|
|
|
220
241
|
}
|
|
221
242
|
}
|
|
222
243
|
|
|
244
|
+
/**
|
|
245
|
+
* TBD.
|
|
246
|
+
* @param {number} time - TBD.
|
|
247
|
+
*/
|
|
223
248
|
update(time) {
|
|
224
249
|
this.time.update(time);
|
|
225
250
|
if (!this.isPaused) {
|
|
@@ -240,6 +265,9 @@ export class Game {
|
|
|
240
265
|
this.renderer.render(this.stage);
|
|
241
266
|
}
|
|
242
267
|
|
|
268
|
+
/**
|
|
269
|
+
* TBD.
|
|
270
|
+
*/
|
|
243
271
|
destroy() {
|
|
244
272
|
this.isPaused = true;
|
|
245
273
|
|
package/src/phaser/core/input.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
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
1
|
import { ArraySet } from './array_set';
|
|
7
|
-
import { Graphics } from
|
|
2
|
+
import { Graphics } from '../display/graphics';
|
|
8
3
|
import { Image } from '../display/image';
|
|
9
|
-
import { Signal } from
|
|
4
|
+
import { Signal } from './signal';
|
|
10
5
|
import { Point } from '../geom/point';
|
|
11
|
-
import { Circle } from
|
|
6
|
+
import { Circle } from '../geom/circle';
|
|
12
7
|
import { Mouse } from './input_mouse';
|
|
13
8
|
import { MSPointer } from './input_mspointer';
|
|
14
9
|
import { Pointer } from './input_pointer';
|
|
15
10
|
import { Touch } from './input_touch';
|
|
16
11
|
import { POINTER_CURSOR, POINTER_CONTACT, MOUSE_TOUCH_COMBINE } from './const';
|
|
17
12
|
import { create, remove } from '../display/canvas/pool';
|
|
13
|
+
import { Game } from './game';
|
|
18
14
|
|
|
19
15
|
const MAX_POINTERS = 10;
|
|
20
16
|
|
|
21
17
|
export class Input {
|
|
18
|
+
/**
|
|
19
|
+
* TBD.
|
|
20
|
+
* @param {Game} game - TBD.
|
|
21
|
+
*/
|
|
22
22
|
constructor(game) {
|
|
23
23
|
this.game = game;
|
|
24
24
|
this.hitCanvas = null;
|
|
@@ -73,6 +73,9 @@ export class Input {
|
|
|
73
73
|
this._y = 0;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* TBD.
|
|
78
|
+
*/
|
|
76
79
|
boot() {
|
|
77
80
|
this.mousePointer = new Pointer(this.game, 0, POINTER_CURSOR);
|
|
78
81
|
this.addPointer();
|
|
@@ -104,6 +107,9 @@ export class Input {
|
|
|
104
107
|
this.game.canvas.addEventListener('click', this._onClickTrampoline, false);
|
|
105
108
|
}
|
|
106
109
|
|
|
110
|
+
/**
|
|
111
|
+
* TBD.
|
|
112
|
+
*/
|
|
107
113
|
destroy() {
|
|
108
114
|
this.mouse.stop();
|
|
109
115
|
if (this.game.device.mspointer) {
|
|
@@ -116,29 +122,44 @@ export class Input {
|
|
|
116
122
|
this.game.canvas.removeEventListener('click', this._onClickTrampoline);
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/**
|
|
126
|
+
* TBD.
|
|
127
|
+
* @param callback - TBD.
|
|
128
|
+
* @param context
|
|
129
|
+
*/
|
|
119
130
|
setInteractiveCandidateHandler(callback, context) {
|
|
120
131
|
this.customCandidateHandler = callback;
|
|
121
132
|
this.customCandidateHandlerContext = context;
|
|
122
133
|
}
|
|
123
134
|
|
|
135
|
+
/**
|
|
136
|
+
* TBD.
|
|
137
|
+
* @param callback - TBD.
|
|
138
|
+
* @param context
|
|
139
|
+
*/
|
|
124
140
|
addMoveCallback(callback, context) {
|
|
125
141
|
this.moveCallbacks.push({ callback, context });
|
|
126
142
|
}
|
|
127
143
|
|
|
144
|
+
/**
|
|
145
|
+
* TBD.
|
|
146
|
+
* @param callback - TBD.
|
|
147
|
+
* @param context
|
|
148
|
+
*/
|
|
128
149
|
deleteMoveCallback(callback, context) {
|
|
129
150
|
let i = this.moveCallbacks.length;
|
|
130
151
|
while (i) {
|
|
131
152
|
i -= 1;
|
|
132
|
-
if (
|
|
133
|
-
this.moveCallbacks[i].callback === callback &&
|
|
134
|
-
this.moveCallbacks[i].context === context
|
|
135
|
-
) {
|
|
153
|
+
if (this.moveCallbacks[i].callback === callback && this.moveCallbacks[i].context === context) {
|
|
136
154
|
this.moveCallbacks.splice(i, 1);
|
|
137
155
|
return;
|
|
138
156
|
}
|
|
139
157
|
}
|
|
140
158
|
}
|
|
141
159
|
|
|
160
|
+
/**
|
|
161
|
+
* TBD.
|
|
162
|
+
*/
|
|
142
163
|
addPointer() {
|
|
143
164
|
if (this.pointers.length >= MAX_POINTERS) {
|
|
144
165
|
console.warn('Input.addPointer: Maximum limit of ' + MAX_POINTERS + ' pointers reached.');
|
|
@@ -151,6 +172,9 @@ export class Input {
|
|
|
151
172
|
return pointer;
|
|
152
173
|
}
|
|
153
174
|
|
|
175
|
+
/**
|
|
176
|
+
* TBD.
|
|
177
|
+
*/
|
|
154
178
|
update() {
|
|
155
179
|
if (this.pollRate > 0 && this._pollCounter < this.pollRate) {
|
|
156
180
|
this._pollCounter += 1;
|
|
@@ -166,6 +190,10 @@ export class Input {
|
|
|
166
190
|
this._pollCounter = 0;
|
|
167
191
|
}
|
|
168
192
|
|
|
193
|
+
/**
|
|
194
|
+
* TBD.
|
|
195
|
+
* @param hard
|
|
196
|
+
*/
|
|
169
197
|
reset(hard = false) {
|
|
170
198
|
if (!this.game.isBooted || this.resetLocked) {
|
|
171
199
|
return;
|
|
@@ -191,11 +219,20 @@ export class Input {
|
|
|
191
219
|
this._pollCounter = 0;
|
|
192
220
|
}
|
|
193
221
|
|
|
222
|
+
/**
|
|
223
|
+
* TBD.
|
|
224
|
+
* @param {number} x - TBD.
|
|
225
|
+
* @param {number} y - TBD.
|
|
226
|
+
*/
|
|
194
227
|
resetSpeed(x, y) {
|
|
195
228
|
this._oldPosition.setTo(x, y);
|
|
196
229
|
this.speed.setTo(0, 0);
|
|
197
230
|
}
|
|
198
231
|
|
|
232
|
+
/**
|
|
233
|
+
* TBD.
|
|
234
|
+
* @param event
|
|
235
|
+
*/
|
|
199
236
|
startPointer(event) {
|
|
200
237
|
if (this.maxPointers >= 0 && this.countActivePointers(this.maxPointers) >= this.maxPointers) {
|
|
201
238
|
return null;
|
|
@@ -215,6 +252,10 @@ export class Input {
|
|
|
215
252
|
return null;
|
|
216
253
|
}
|
|
217
254
|
|
|
255
|
+
/**
|
|
256
|
+
* TBD.
|
|
257
|
+
* @param event
|
|
258
|
+
*/
|
|
218
259
|
updatePointer(event) {
|
|
219
260
|
if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
|
|
220
261
|
return this.pointer1.move(event);
|
|
@@ -231,6 +272,10 @@ export class Input {
|
|
|
231
272
|
return null;
|
|
232
273
|
}
|
|
233
274
|
|
|
275
|
+
/**
|
|
276
|
+
* TBD.
|
|
277
|
+
* @param event
|
|
278
|
+
*/
|
|
234
279
|
stopPointer(event) {
|
|
235
280
|
if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
|
|
236
281
|
return this.pointer1.stop(event);
|
|
@@ -247,6 +292,10 @@ export class Input {
|
|
|
247
292
|
return null;
|
|
248
293
|
}
|
|
249
294
|
|
|
295
|
+
/**
|
|
296
|
+
* TBD.
|
|
297
|
+
* @param limit
|
|
298
|
+
*/
|
|
250
299
|
countActivePointers(limit = this.pointers.length) {
|
|
251
300
|
let count = limit;
|
|
252
301
|
for (let i = 0; i < this.pointers.length && count > 0; i += 1) {
|
|
@@ -258,6 +307,10 @@ export class Input {
|
|
|
258
307
|
return limit - count;
|
|
259
308
|
}
|
|
260
309
|
|
|
310
|
+
/**
|
|
311
|
+
* TBD.
|
|
312
|
+
* @param isActive
|
|
313
|
+
*/
|
|
261
314
|
getPointer(isActive = false) {
|
|
262
315
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
263
316
|
const pointer = this.pointers[i];
|
|
@@ -268,6 +321,10 @@ export class Input {
|
|
|
268
321
|
return null;
|
|
269
322
|
}
|
|
270
323
|
|
|
324
|
+
/**
|
|
325
|
+
* TBD.
|
|
326
|
+
* @param identifier
|
|
327
|
+
*/
|
|
271
328
|
getPointerFromIdentifier(identifier) {
|
|
272
329
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
273
330
|
const pointer = this.pointers[i];
|
|
@@ -279,6 +336,10 @@ export class Input {
|
|
|
279
336
|
return null;
|
|
280
337
|
}
|
|
281
338
|
|
|
339
|
+
/**
|
|
340
|
+
* TBD.
|
|
341
|
+
* @param pointerId
|
|
342
|
+
*/
|
|
282
343
|
getPointerFromId(pointerId) {
|
|
283
344
|
for (let i = 0; i < this.pointers.length; i += 1) {
|
|
284
345
|
const pointer = this.pointers[i];
|
|
@@ -290,6 +351,12 @@ export class Input {
|
|
|
290
351
|
return null;
|
|
291
352
|
}
|
|
292
353
|
|
|
354
|
+
/**
|
|
355
|
+
* TBD.
|
|
356
|
+
* @param displayObject
|
|
357
|
+
* @param pointer
|
|
358
|
+
* @param output
|
|
359
|
+
*/
|
|
293
360
|
getLocalPosition(displayObject, pointer, output = null) {
|
|
294
361
|
const result = output || new Point();
|
|
295
362
|
const wt = displayObject.worldTransform;
|
|
@@ -300,6 +367,12 @@ export class Input {
|
|
|
300
367
|
);
|
|
301
368
|
}
|
|
302
369
|
|
|
370
|
+
/**
|
|
371
|
+
* TBD.
|
|
372
|
+
* @param displayObject
|
|
373
|
+
* @param pointer
|
|
374
|
+
* @param localPoint
|
|
375
|
+
*/
|
|
303
376
|
hitTest(displayObject, pointer, localPoint) {
|
|
304
377
|
if (!displayObject.worldVisible) {
|
|
305
378
|
return false;
|
|
@@ -321,11 +394,7 @@ export class Input {
|
|
|
321
394
|
} else if (displayObject instanceof Graphics) {
|
|
322
395
|
for (let i = 0; i < displayObject.graphicsData.length; i += 1) {
|
|
323
396
|
const data = displayObject.graphicsData[i];
|
|
324
|
-
if (
|
|
325
|
-
data.fill &&
|
|
326
|
-
data.shape &&
|
|
327
|
-
data.shape.contains(this._localPoint.x, this._localPoint.y)
|
|
328
|
-
) {
|
|
397
|
+
if (data.fill && data.shape && data.shape.contains(this._localPoint.x, this._localPoint.y)) {
|
|
329
398
|
// Only deal with fills..
|
|
330
399
|
return true;
|
|
331
400
|
}
|
|
@@ -340,42 +409,72 @@ export class Input {
|
|
|
340
409
|
return false;
|
|
341
410
|
}
|
|
342
411
|
|
|
412
|
+
/**
|
|
413
|
+
* TBD.
|
|
414
|
+
*/
|
|
343
415
|
onClickTrampoline() {
|
|
344
416
|
this.activePointer.processClickTrampolines();
|
|
345
417
|
}
|
|
346
418
|
|
|
419
|
+
/**
|
|
420
|
+
* TBD.
|
|
421
|
+
*/
|
|
347
422
|
get x() {
|
|
348
423
|
return this._x;
|
|
349
424
|
}
|
|
350
425
|
|
|
426
|
+
/**
|
|
427
|
+
* TBD.
|
|
428
|
+
*/
|
|
351
429
|
set x(value) {
|
|
352
430
|
this._x = Math.floor(value);
|
|
353
431
|
}
|
|
354
432
|
|
|
433
|
+
/**
|
|
434
|
+
* TBD.
|
|
435
|
+
*/
|
|
355
436
|
get y() {
|
|
356
437
|
return this._y;
|
|
357
438
|
}
|
|
358
439
|
|
|
440
|
+
/**
|
|
441
|
+
* TBD.
|
|
442
|
+
*/
|
|
359
443
|
set y(value) {
|
|
360
444
|
this._y = Math.floor(value);
|
|
361
445
|
}
|
|
362
446
|
|
|
447
|
+
/**
|
|
448
|
+
* TBD.
|
|
449
|
+
*/
|
|
363
450
|
get pollLocked() {
|
|
364
451
|
return this.pollRate > 0 && this._pollCounter < this.pollRate;
|
|
365
452
|
}
|
|
366
453
|
|
|
454
|
+
/**
|
|
455
|
+
* TBD.
|
|
456
|
+
*/
|
|
367
457
|
get totalInactivePointers() {
|
|
368
458
|
return this.pointers.length - this.countActivePointers();
|
|
369
459
|
}
|
|
370
460
|
|
|
461
|
+
/**
|
|
462
|
+
* TBD.
|
|
463
|
+
*/
|
|
371
464
|
get totalActivePointers() {
|
|
372
465
|
return this.countActivePointers();
|
|
373
466
|
}
|
|
374
467
|
|
|
468
|
+
/**
|
|
469
|
+
* TBD.
|
|
470
|
+
*/
|
|
375
471
|
get worldX() {
|
|
376
472
|
return this.x;
|
|
377
473
|
}
|
|
378
474
|
|
|
475
|
+
/**
|
|
476
|
+
* TBD.
|
|
477
|
+
*/
|
|
379
478
|
get worldY() {
|
|
380
479
|
return this.y;
|
|
381
480
|
}
|