@vpmedia/phaser 1.11.0 → 1.12.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/phaser/core/animation.js +9 -6
- package/src/phaser/core/animation_manager.js +14 -4
- package/src/phaser/core/animation_parser.js +24 -3
- package/src/phaser/core/array_set.js +1 -3
- package/src/phaser/core/cache.js +6 -6
- package/src/phaser/core/device.js +0 -2
- package/src/phaser/core/device_util.js +21 -6
- package/src/phaser/core/dom.js +34 -25
- package/src/phaser/core/event_manager.js +45 -17
- package/src/phaser/core/factory.js +26 -4
- package/src/phaser/core/frame.js +0 -2
- package/src/phaser/core/frame_data.js +0 -2
- package/src/phaser/core/game.js +8 -6
- package/src/phaser/core/input.js +17 -9
- package/src/phaser/core/input_handler.js +100 -26
- package/src/phaser/core/input_mouse.js +10 -14
- package/src/phaser/core/input_mspointer.js +10 -9
- package/src/phaser/core/input_pointer.js +58 -17
- package/src/phaser/core/input_touch.js +6 -8
- package/src/phaser/core/loader.js +168 -51
- package/src/phaser/core/loader_parser.js +4 -1
- package/src/phaser/core/raf.js +0 -2
- package/src/phaser/core/scale_manager.js +69 -25
- package/src/phaser/core/scene.js +0 -2
- package/src/phaser/core/scene_manager.js +6 -3
- package/src/phaser/core/signal.js +15 -8
- package/src/phaser/core/signal_binding.js +10 -5
- package/src/phaser/core/sound.js +20 -11
- package/src/phaser/core/sound_manager.js +56 -20
- package/src/phaser/core/sound_sprite.js +32 -32
- package/src/phaser/core/stage.js +0 -3
- package/src/phaser/core/time.js +0 -2
- package/src/phaser/core/timer.js +24 -7
- package/src/phaser/core/timer_event.js +0 -2
- package/src/phaser/core/tween.js +32 -8
- package/src/phaser/core/tween_data.js +15 -7
- package/src/phaser/core/tween_easing.js +24 -20
- package/src/phaser/core/tween_manager.js +31 -13
- package/src/phaser/core/world.js +0 -2
- package/src/phaser/display/bitmap_text.js +8 -9
- package/src/phaser/display/button.js +16 -4
- package/src/phaser/display/canvas/buffer.js +0 -2
- package/src/phaser/display/canvas/graphics.js +21 -9
- package/src/phaser/display/canvas/masker.js +1 -1
- package/src/phaser/display/canvas/renderer.js +39 -19
- package/src/phaser/display/canvas/tinter.js +43 -6
- package/src/phaser/display/canvas/util.js +1 -1
- package/src/phaser/display/display_object.js +33 -19
- package/src/phaser/display/graphics.js +52 -27
- package/src/phaser/display/graphics_data.js +0 -2
- package/src/phaser/display/graphics_data_util.js +9 -1
- package/src/phaser/display/group.js +1 -4
- package/src/phaser/display/image.js +2 -4
- package/src/phaser/display/sprite_batch.js +0 -2
- package/src/phaser/display/sprite_util.js +46 -11
- package/src/phaser/display/text.js +77 -26
- package/src/phaser/display/webgl/abstract_filter.js +0 -2
- package/src/phaser/display/webgl/base_texture.js +5 -3
- package/src/phaser/display/webgl/blend_manager.js +0 -2
- package/src/phaser/display/webgl/earcut.js +63 -22
- package/src/phaser/display/webgl/earcut_node.js +0 -2
- package/src/phaser/display/webgl/fast_sprite_batch.js +47 -46
- package/src/phaser/display/webgl/filter_manager.js +0 -2
- package/src/phaser/display/webgl/filter_texture.js +16 -5
- package/src/phaser/display/webgl/graphics.js +38 -16
- package/src/phaser/display/webgl/graphics_data.js +0 -2
- package/src/phaser/display/webgl/mask_manager.js +10 -2
- package/src/phaser/display/webgl/render_texture.js +14 -5
- package/src/phaser/display/webgl/renderer.js +39 -7
- package/src/phaser/display/webgl/shader/complex.js +0 -2
- package/src/phaser/display/webgl/shader/fast.js +8 -3
- package/src/phaser/display/webgl/shader/normal.js +42 -14
- package/src/phaser/display/webgl/shader/primitive.js +0 -2
- package/src/phaser/display/webgl/shader/strip.js +0 -2
- package/src/phaser/display/webgl/shader_manager.js +0 -2
- package/src/phaser/display/webgl/sprite_batch.js +13 -14
- package/src/phaser/display/webgl/stencil_manager.js +18 -20
- package/src/phaser/display/webgl/texture.js +10 -7
- package/src/phaser/display/webgl/util.js +1 -2
- package/src/phaser/geom/circle.js +15 -7
- package/src/phaser/geom/ellipse.js +13 -6
- package/src/phaser/geom/line.js +19 -10
- package/src/phaser/geom/matrix.js +0 -2
- package/src/phaser/geom/point.js +9 -11
- package/src/phaser/geom/polygon.js +9 -5
- package/src/phaser/geom/rectangle.js +44 -10
- package/src/phaser/geom/rounded_rectangle.js +0 -2
- package/src/phaser/geom/util/circle.js +3 -3
- package/src/phaser/geom/util/ellipse.js +3 -3
- package/src/phaser/geom/util/line.js +16 -13
- package/src/phaser/geom/util/point.js +1 -1
- package/src/phaser/geom/util/rectangle.js +17 -7
- package/src/phaser/util/math.js +37 -23
- package/tsconfig.json +110 -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 +20 -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 +48 -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 +15 -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 +35 -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 +48 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +33 -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 +18 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +12 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +45 -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 +36 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +70 -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 +53 -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 +7 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +41 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +43 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +6 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +35 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +116 -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 +13 -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 +15 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +41 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +39 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +18 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +37 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +25 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +37 -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 +63 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +55 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +21 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +42 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +20 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +157 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +15 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +124 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +15 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +162 -0
- package/types/phaser/util/math.d.ts.map +1 -0
package/src/phaser/core/game.js
CHANGED
|
@@ -24,7 +24,6 @@ import { create, removeFromDOM, addToDOM, setTouchAction } from '../display/canv
|
|
|
24
24
|
import { initialize, checkOS } from './device_util';
|
|
25
25
|
|
|
26
26
|
export default class {
|
|
27
|
-
|
|
28
27
|
constructor(gameConfig = {}) {
|
|
29
28
|
if (!window.PhaserRegistry) {
|
|
30
29
|
window.PhaserRegistry = {};
|
|
@@ -61,10 +60,14 @@ export default class {
|
|
|
61
60
|
initialize(this.device);
|
|
62
61
|
this.boot();
|
|
63
62
|
} else {
|
|
64
|
-
window.addEventListener(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
window.addEventListener(
|
|
64
|
+
'load',
|
|
65
|
+
() => {
|
|
66
|
+
initialize(this.device);
|
|
67
|
+
this.boot();
|
|
68
|
+
},
|
|
69
|
+
false
|
|
70
|
+
);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -276,5 +279,4 @@ export default class {
|
|
|
276
279
|
this.canvas = null;
|
|
277
280
|
this.renderer = null;
|
|
278
281
|
}
|
|
279
|
-
|
|
280
282
|
}
|
package/src/phaser/core/input.js
CHANGED
|
@@ -19,7 +19,6 @@ import { create, remove } from '../display/canvas/pool';
|
|
|
19
19
|
const MAX_POINTERS = 10;
|
|
20
20
|
|
|
21
21
|
export default class {
|
|
22
|
-
|
|
23
22
|
constructor(game) {
|
|
24
23
|
this.game = game;
|
|
25
24
|
this.hitCanvas = null;
|
|
@@ -101,7 +100,7 @@ export default class {
|
|
|
101
100
|
}
|
|
102
101
|
this.mousePointer.active = true;
|
|
103
102
|
const scope = this;
|
|
104
|
-
this._onClickTrampoline = event => scope.onClickTrampoline(event);
|
|
103
|
+
this._onClickTrampoline = (event) => scope.onClickTrampoline(event);
|
|
105
104
|
this.game.canvas.addEventListener('click', this._onClickTrampoline, false);
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -130,7 +129,10 @@ export default class {
|
|
|
130
129
|
let i = this.moveCallbacks.length;
|
|
131
130
|
while (i) {
|
|
132
131
|
i -= 1;
|
|
133
|
-
if (
|
|
132
|
+
if (
|
|
133
|
+
this.moveCallbacks[i].callback === callback &&
|
|
134
|
+
this.moveCallbacks[i].context === context
|
|
135
|
+
) {
|
|
134
136
|
this.moveCallbacks.splice(i, 1);
|
|
135
137
|
return;
|
|
136
138
|
}
|
|
@@ -253,7 +255,7 @@ export default class {
|
|
|
253
255
|
count -= 1;
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
|
-
return
|
|
258
|
+
return limit - count;
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
getPointer(isActive = false) {
|
|
@@ -292,7 +294,10 @@ export default class {
|
|
|
292
294
|
const result = output || new Point();
|
|
293
295
|
const wt = displayObject.worldTransform;
|
|
294
296
|
const id = 1 / (wt.a * wt.d + wt.c * -wt.b);
|
|
295
|
-
return result.setTo(
|
|
297
|
+
return result.setTo(
|
|
298
|
+
wt.d * id * pointer.x + -wt.c * id * pointer.y + (wt.ty * wt.c - wt.tx * wt.d) * id,
|
|
299
|
+
wt.a * id * pointer.y + -wt.b * id * pointer.x + (-wt.ty * wt.a + wt.tx * wt.b) * id
|
|
300
|
+
);
|
|
296
301
|
}
|
|
297
302
|
|
|
298
303
|
hitTest(displayObject, pointer, localPoint) {
|
|
@@ -302,7 +307,7 @@ export default class {
|
|
|
302
307
|
this.getLocalPosition(displayObject, pointer, this._localPoint);
|
|
303
308
|
localPoint.copyFrom(this._localPoint);
|
|
304
309
|
if (displayObject.hitArea && displayObject.hitArea.contains) {
|
|
305
|
-
return
|
|
310
|
+
return displayObject.hitArea.contains(this._localPoint.x, this._localPoint.y);
|
|
306
311
|
} else if (displayObject instanceof Image) {
|
|
307
312
|
const width = displayObject.texture.frame.width;
|
|
308
313
|
const height = displayObject.texture.frame.height;
|
|
@@ -316,7 +321,11 @@ export default class {
|
|
|
316
321
|
} else if (displayObject instanceof Graphics) {
|
|
317
322
|
for (let i = 0; i < displayObject.graphicsData.length; i += 1) {
|
|
318
323
|
const data = displayObject.graphicsData[i];
|
|
319
|
-
if (
|
|
324
|
+
if (
|
|
325
|
+
data.fill &&
|
|
326
|
+
data.shape &&
|
|
327
|
+
data.shape.contains(this._localPoint.x, this._localPoint.y)
|
|
328
|
+
) {
|
|
320
329
|
// Only deal with fills..
|
|
321
330
|
return true;
|
|
322
331
|
}
|
|
@@ -352,7 +361,7 @@ export default class {
|
|
|
352
361
|
}
|
|
353
362
|
|
|
354
363
|
get pollLocked() {
|
|
355
|
-
return
|
|
364
|
+
return this.pollRate > 0 && this._pollCounter < this.pollRate;
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
get totalInactivePointers() {
|
|
@@ -370,5 +379,4 @@ export default class {
|
|
|
370
379
|
get worldY() {
|
|
371
380
|
return this.y;
|
|
372
381
|
}
|
|
373
|
-
|
|
374
382
|
}
|
|
@@ -8,7 +8,6 @@ import { GROUP } from './const';
|
|
|
8
8
|
import { distance } from '../util/math';
|
|
9
9
|
|
|
10
10
|
export default class {
|
|
11
|
-
|
|
12
11
|
constructor(sprite) {
|
|
13
12
|
this.sprite = sprite;
|
|
14
13
|
this.game = sprite.game;
|
|
@@ -165,25 +164,33 @@ export default class {
|
|
|
165
164
|
this.boundsSprite = null;
|
|
166
165
|
this.sprite = null;
|
|
167
166
|
}
|
|
168
|
-
|
|
169
167
|
}
|
|
170
168
|
|
|
171
169
|
validForInput(highestID, highestRenderID, includePixelPerfect = true) {
|
|
172
|
-
if (
|
|
170
|
+
if (
|
|
171
|
+
!this.enabled ||
|
|
172
|
+
this.sprite.scale.x === 0 ||
|
|
173
|
+
this.sprite.scale.y === 0 ||
|
|
174
|
+
this.priorityID < this.game.input.minPriorityID ||
|
|
175
|
+
(this.sprite.parent && this.sprite.parent.ignoreChildInput)
|
|
176
|
+
) {
|
|
173
177
|
return false;
|
|
174
178
|
}
|
|
175
179
|
// If we're trying to specifically IGNORE pixel perfect objects, then set includePixelPerfect to false and skip it
|
|
176
180
|
if (!includePixelPerfect && (this.pixelPerfectClick || this.pixelPerfectOver)) {
|
|
177
181
|
return false;
|
|
178
182
|
}
|
|
179
|
-
if (
|
|
183
|
+
if (
|
|
184
|
+
this.priorityID > highestID ||
|
|
185
|
+
(this.priorityID === highestID && this.sprite.renderOrderID > highestRenderID)
|
|
186
|
+
) {
|
|
180
187
|
return true;
|
|
181
188
|
}
|
|
182
189
|
return false;
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
isPixelPerfect() {
|
|
186
|
-
return
|
|
193
|
+
return this.pixelPerfectClick || this.pixelPerfectOver;
|
|
187
194
|
}
|
|
188
195
|
|
|
189
196
|
pointerX(pointerId = 0) {
|
|
@@ -252,7 +259,16 @@ export default class {
|
|
|
252
259
|
}
|
|
253
260
|
|
|
254
261
|
checkPointerDown(pointer = 0, fastTest = false) {
|
|
255
|
-
if (
|
|
262
|
+
if (
|
|
263
|
+
!pointer.isDown ||
|
|
264
|
+
!this.enabled ||
|
|
265
|
+
!this.sprite ||
|
|
266
|
+
!this.sprite.parent ||
|
|
267
|
+
!this.sprite.visible ||
|
|
268
|
+
!this.sprite.parent.visible ||
|
|
269
|
+
this.sprite.worldScale.x === 0 ||
|
|
270
|
+
this.sprite.worldScale.y === 0
|
|
271
|
+
) {
|
|
256
272
|
return false;
|
|
257
273
|
}
|
|
258
274
|
// Need to pass it a temp point, in case we need it again for the pixel check
|
|
@@ -266,7 +282,15 @@ export default class {
|
|
|
266
282
|
}
|
|
267
283
|
|
|
268
284
|
checkPointerOver(pointer = 0, fastTest = false) {
|
|
269
|
-
if (
|
|
285
|
+
if (
|
|
286
|
+
!this.enabled ||
|
|
287
|
+
!this.sprite ||
|
|
288
|
+
!this.sprite.parent ||
|
|
289
|
+
!this.sprite.visible ||
|
|
290
|
+
!this.sprite.parent.visible ||
|
|
291
|
+
this.sprite.worldScale.x === 0 ||
|
|
292
|
+
this.sprite.worldScale.y === 0
|
|
293
|
+
) {
|
|
270
294
|
return false;
|
|
271
295
|
}
|
|
272
296
|
// Need to pass it a temp point, in case we need it again for the pixel check
|
|
@@ -300,7 +324,12 @@ export default class {
|
|
|
300
324
|
x -= this.sprite.texture.trim.x;
|
|
301
325
|
y -= this.sprite.texture.trim.y;
|
|
302
326
|
// If the coordinates are outside the trim area we return false immediately, to save doing a draw call
|
|
303
|
-
if (
|
|
327
|
+
if (
|
|
328
|
+
x < this.sprite.texture.crop.x ||
|
|
329
|
+
x > this.sprite.texture.crop.right ||
|
|
330
|
+
y < this.sprite.texture.crop.y ||
|
|
331
|
+
y > this.sprite.texture.crop.bottom
|
|
332
|
+
) {
|
|
304
333
|
this._dx = x;
|
|
305
334
|
this._dy = y;
|
|
306
335
|
return false;
|
|
@@ -309,7 +338,17 @@ export default class {
|
|
|
309
338
|
this._dx = x;
|
|
310
339
|
this._dy = y;
|
|
311
340
|
this.game.input.hitContext.clearRect(0, 0, 1, 1);
|
|
312
|
-
this.game.input.hitContext.drawImage(
|
|
341
|
+
this.game.input.hitContext.drawImage(
|
|
342
|
+
this.sprite.texture.baseTexture.source,
|
|
343
|
+
x,
|
|
344
|
+
y,
|
|
345
|
+
1,
|
|
346
|
+
1,
|
|
347
|
+
0,
|
|
348
|
+
0,
|
|
349
|
+
1,
|
|
350
|
+
1
|
|
351
|
+
);
|
|
313
352
|
const rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1);
|
|
314
353
|
if (rgb.data[3] >= this.pixelPerfectAlpha) {
|
|
315
354
|
return true;
|
|
@@ -329,7 +368,9 @@ export default class {
|
|
|
329
368
|
}
|
|
330
369
|
if (this._pendingDrag) {
|
|
331
370
|
if (!this._dragDistancePass) {
|
|
332
|
-
this._dragDistancePass =
|
|
371
|
+
this._dragDistancePass =
|
|
372
|
+
distance(pointer.x, pointer.y, this.downPoint.x, this.downPoint.y) >=
|
|
373
|
+
this.dragDistanceThreshold;
|
|
333
374
|
}
|
|
334
375
|
if (this._dragDistancePass && this._dragTimePass) {
|
|
335
376
|
this.startDrag(pointer);
|
|
@@ -356,7 +397,7 @@ export default class {
|
|
|
356
397
|
}
|
|
357
398
|
const data = this._pointerData[pointer.id];
|
|
358
399
|
if (data.isOver === false || pointer.dirty) {
|
|
359
|
-
const sendEvent =
|
|
400
|
+
const sendEvent = data.isOver === false;
|
|
360
401
|
data.isOver = true;
|
|
361
402
|
data.isOut = false;
|
|
362
403
|
data.timeOver = this.game.time.time;
|
|
@@ -429,7 +470,7 @@ export default class {
|
|
|
429
470
|
this.startDrag(pointer);
|
|
430
471
|
} else {
|
|
431
472
|
this._pendingDrag = true;
|
|
432
|
-
this._dragDistancePass =
|
|
473
|
+
this._dragDistancePass = this.dragDistanceThreshold === 0;
|
|
433
474
|
if (this.dragTimeThreshold > 0) {
|
|
434
475
|
this._dragTimePass = false;
|
|
435
476
|
this.game.time.events.add(this.dragTimeThreshold, this.dragTimeElapsed, this, pointer);
|
|
@@ -468,7 +509,11 @@ export default class {
|
|
|
468
509
|
// Only release the InputUp signal if the pointer is still over this sprite
|
|
469
510
|
let isOver = this.checkPointerOver(pointer);
|
|
470
511
|
if (this.sprite && this.sprite.events) {
|
|
471
|
-
if (
|
|
512
|
+
if (
|
|
513
|
+
!this.dragStopBlocksInputUp ||
|
|
514
|
+
(this.dragStopBlocksInputUp &&
|
|
515
|
+
!(this.draggable && this.isDragged && this._draggedPointerID === pointer.id))
|
|
516
|
+
) {
|
|
472
517
|
this.sprite.events.onInputUp$dispatch(this.sprite, pointer, isOver);
|
|
473
518
|
}
|
|
474
519
|
if (this.sprite && this.sprite.parent && this.sprite.parent.type === GROUP) {
|
|
@@ -516,28 +561,45 @@ export default class {
|
|
|
516
561
|
this.checkBoundsSprite();
|
|
517
562
|
}
|
|
518
563
|
if (this.snapOnDrag) {
|
|
519
|
-
this.sprite.x =
|
|
520
|
-
|
|
564
|
+
this.sprite.x =
|
|
565
|
+
Math.round((this.sprite.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX +
|
|
566
|
+
(this.snapOffsetX % this.snapX);
|
|
567
|
+
this.sprite.y =
|
|
568
|
+
Math.round((this.sprite.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY +
|
|
569
|
+
(this.snapOffsetY % this.snapY);
|
|
521
570
|
this.snapPoint.set(this.sprite.x, this.sprite.y);
|
|
522
571
|
}
|
|
523
|
-
this.sprite.events.onDragUpdate.dispatch(
|
|
572
|
+
this.sprite.events.onDragUpdate.dispatch(
|
|
573
|
+
this.sprite,
|
|
574
|
+
pointer,
|
|
575
|
+
px,
|
|
576
|
+
py,
|
|
577
|
+
this.snapPoint,
|
|
578
|
+
fromStart
|
|
579
|
+
);
|
|
524
580
|
return true;
|
|
525
581
|
}
|
|
526
582
|
|
|
527
583
|
justOver(pointerId = 0, delay = 500) {
|
|
528
|
-
return
|
|
584
|
+
return this._pointerData[pointerId].isOver && this.overDuration(pointerId) < delay;
|
|
529
585
|
}
|
|
530
586
|
|
|
531
587
|
justOut(pointerId = 0, delay = 500) {
|
|
532
|
-
return (
|
|
588
|
+
return (
|
|
589
|
+
this._pointerData[pointerId].isOut &&
|
|
590
|
+
this.game.time.time - this._pointerData[pointerId].timeOut < delay
|
|
591
|
+
);
|
|
533
592
|
}
|
|
534
593
|
|
|
535
594
|
justPressed(pointerId = 0, delay = 500) {
|
|
536
|
-
return
|
|
595
|
+
return this._pointerData[pointerId].isDown && this.downDuration(pointerId) < delay;
|
|
537
596
|
}
|
|
538
597
|
|
|
539
598
|
justReleased(pointerId = 0, delay = 500) {
|
|
540
|
-
return (
|
|
599
|
+
return (
|
|
600
|
+
this._pointerData[pointerId].isUp &&
|
|
601
|
+
this.game.time.time - this._pointerData[pointerId].timeUp < delay
|
|
602
|
+
);
|
|
541
603
|
}
|
|
542
604
|
|
|
543
605
|
overDuration(pointerId = 0) {
|
|
@@ -554,7 +616,14 @@ export default class {
|
|
|
554
616
|
return -1;
|
|
555
617
|
}
|
|
556
618
|
|
|
557
|
-
enableDrag(
|
|
619
|
+
enableDrag(
|
|
620
|
+
lockCenter = false,
|
|
621
|
+
bringToTop = false,
|
|
622
|
+
pixelPerfect = false,
|
|
623
|
+
alphaThreshold = 255,
|
|
624
|
+
boundsRect = null,
|
|
625
|
+
boundsSprite = null
|
|
626
|
+
) {
|
|
558
627
|
this._dragPoint = new Point();
|
|
559
628
|
this.draggable = true;
|
|
560
629
|
this.bringToTop = bringToTop;
|
|
@@ -595,7 +664,10 @@ export default class {
|
|
|
595
664
|
this.sprite.x = this.globalToLocalX(pointer.x) + (this.sprite.x - bounds.centerX);
|
|
596
665
|
this.sprite.y = this.globalToLocalY(pointer.y) + (this.sprite.y - bounds.centerY);
|
|
597
666
|
}
|
|
598
|
-
this._dragPoint.setTo(
|
|
667
|
+
this._dragPoint.setTo(
|
|
668
|
+
this.sprite.x - this.globalToLocalX(pointer.x),
|
|
669
|
+
this.sprite.y - this.globalToLocalY(pointer.y)
|
|
670
|
+
);
|
|
599
671
|
this.updateDrag(pointer, true);
|
|
600
672
|
if (this.bringToTop) {
|
|
601
673
|
this._dragPhase = true;
|
|
@@ -629,8 +701,12 @@ export default class {
|
|
|
629
701
|
this._dragPhase = false;
|
|
630
702
|
this._pendingDrag = false;
|
|
631
703
|
if (this.snapOnRelease) {
|
|
632
|
-
this.sprite.x =
|
|
633
|
-
|
|
704
|
+
this.sprite.x =
|
|
705
|
+
Math.round((this.sprite.x - (this.snapOffsetX % this.snapX)) / this.snapX) * this.snapX +
|
|
706
|
+
(this.snapOffsetX % this.snapX);
|
|
707
|
+
this.sprite.y =
|
|
708
|
+
Math.round((this.sprite.y - (this.snapOffsetY % this.snapY)) / this.snapY) * this.snapY +
|
|
709
|
+
(this.snapOffsetY % this.snapY);
|
|
634
710
|
}
|
|
635
711
|
this.sprite.events.onDragStop$dispatch(this.sprite, pointer);
|
|
636
712
|
if (this.checkPointerOver(pointer) === false) {
|
|
@@ -681,7 +757,5 @@ export default class {
|
|
|
681
757
|
} else if (this.sprite.bottom > this.boundsSprite.bottom) {
|
|
682
758
|
this.sprite.y = this.boundsSprite.bottom - (this.sprite.height - this.sprite.offsetY);
|
|
683
759
|
}
|
|
684
|
-
|
|
685
760
|
}
|
|
686
|
-
|
|
687
761
|
}
|
|
@@ -15,7 +15,6 @@ const WHEEL_UP = 1;
|
|
|
15
15
|
const WHEEL_DOWN = -1;
|
|
16
16
|
|
|
17
17
|
class WheelEventProxy {
|
|
18
|
-
|
|
19
18
|
constructor(scaleFactor, deltaMode) {
|
|
20
19
|
this._scaleFactor = scaleFactor;
|
|
21
20
|
this._deltaMode = deltaMode;
|
|
@@ -47,17 +46,15 @@ class WheelEventProxy {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
get deltaY() {
|
|
50
|
-
return
|
|
49
|
+
return this._scaleFactor * (this.originalEvent.wheelDelta || this.originalEvent.detail) || 0;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
get deltaX() {
|
|
54
|
-
return
|
|
53
|
+
return this._scaleFactor * this.originalEvent.wheelDeltaX || 0;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
export default class {
|
|
60
|
-
|
|
61
58
|
constructor(game) {
|
|
62
59
|
this.game = game;
|
|
63
60
|
this.input = game.input;
|
|
@@ -93,14 +90,14 @@ export default class {
|
|
|
93
90
|
return;
|
|
94
91
|
}
|
|
95
92
|
const scope = this;
|
|
96
|
-
this._onMouseDown = event => scope.onMouseDown(event);
|
|
97
|
-
this._onMouseMove = event => scope.onMouseMove(event);
|
|
98
|
-
this._onMouseUp = event => scope.onMouseUp(event);
|
|
99
|
-
this._onMouseUpGlobal = event => scope.onMouseUpGlobal(event);
|
|
100
|
-
this._onMouseOutGlobal = event => scope.onMouseOutGlobal(event);
|
|
101
|
-
this._onMouseOut = event => scope.onMouseOut(event);
|
|
102
|
-
this._onMouseOver = event => scope.onMouseOver(event);
|
|
103
|
-
this._onMouseWheel = event => scope.onMouseWheel(event);
|
|
93
|
+
this._onMouseDown = (event) => scope.onMouseDown(event);
|
|
94
|
+
this._onMouseMove = (event) => scope.onMouseMove(event);
|
|
95
|
+
this._onMouseUp = (event) => scope.onMouseUp(event);
|
|
96
|
+
this._onMouseUpGlobal = (event) => scope.onMouseUpGlobal(event);
|
|
97
|
+
this._onMouseOutGlobal = (event) => scope.onMouseOutGlobal(event);
|
|
98
|
+
this._onMouseOut = (event) => scope.onMouseOut(event);
|
|
99
|
+
this._onMouseOver = (event) => scope.onMouseOver(event);
|
|
100
|
+
this._onMouseWheel = (event) => scope.onMouseWheel(event);
|
|
104
101
|
const canvas = this.game.canvas;
|
|
105
102
|
canvas.addEventListener('mousedown', this._onMouseDown, true);
|
|
106
103
|
canvas.addEventListener('mousemove', this._onMouseMove, true);
|
|
@@ -239,5 +236,4 @@ export default class {
|
|
|
239
236
|
}
|
|
240
237
|
}
|
|
241
238
|
}
|
|
242
|
-
|
|
243
239
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export default class {
|
|
8
|
-
|
|
9
8
|
constructor(game) {
|
|
10
9
|
this.game = game;
|
|
11
10
|
this.input = game.input;
|
|
@@ -30,12 +29,12 @@ export default class {
|
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
const scope = this;
|
|
33
|
-
this._onMSPointerDown = event => scope.onPointerDown(event);
|
|
34
|
-
this._onMSPointerMove = event => scope.onPointerMove(event);
|
|
35
|
-
this._onMSPointerUp = event => scope.onPointerUp(event);
|
|
36
|
-
this._onMSPointerUpGlobal = event => scope.onPointerUpGlobal(event);
|
|
37
|
-
this._onMSPointerOut = event => scope.onPointerOut(event);
|
|
38
|
-
this._onMSPointerOver = event => scope.onPointerOver(event);
|
|
32
|
+
this._onMSPointerDown = (event) => scope.onPointerDown(event);
|
|
33
|
+
this._onMSPointerMove = (event) => scope.onPointerMove(event);
|
|
34
|
+
this._onMSPointerUp = (event) => scope.onPointerUp(event);
|
|
35
|
+
this._onMSPointerUpGlobal = (event) => scope.onPointerUpGlobal(event);
|
|
36
|
+
this._onMSPointerOut = (event) => scope.onPointerOut(event);
|
|
37
|
+
this._onMSPointerOver = (event) => scope.onPointerOver(event);
|
|
39
38
|
const canvas = this.game.canvas;
|
|
40
39
|
canvas.addEventListener('MSPointerDown', this._onMSPointerDown, false);
|
|
41
40
|
canvas.addEventListener('MSPointerMove', this._onMSPointerMove, false);
|
|
@@ -128,7 +127,10 @@ export default class {
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
onPointerUpGlobal(event) {
|
|
131
|
-
if (
|
|
130
|
+
if (
|
|
131
|
+
(event.pointerType === 'mouse' || event.pointerType === 0x00000004) &&
|
|
132
|
+
!this.input.mousePointer.withinGame
|
|
133
|
+
) {
|
|
132
134
|
this.onPointerUp(event);
|
|
133
135
|
} else {
|
|
134
136
|
const pointer = this.input.getPointerFromIdentifier(event.identifier);
|
|
@@ -189,5 +191,4 @@ export default class {
|
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
|
|
193
194
|
}
|
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import Point from '../geom/point';
|
|
7
7
|
import Circle from '../geom/circle';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
POINTER,
|
|
10
|
+
POINTER_CURSOR,
|
|
11
|
+
POINTER_CONTACT,
|
|
12
|
+
MOUSE_OVERRIDES_TOUCH,
|
|
13
|
+
TOUCH_OVERRIDES_MOUSE,
|
|
14
|
+
MOUSE_TOUCH_COMBINE,
|
|
15
|
+
} from './const';
|
|
9
16
|
|
|
10
17
|
export default class {
|
|
11
|
-
|
|
12
18
|
constructor(game, id, pointerMode) {
|
|
13
19
|
this.game = game;
|
|
14
20
|
this.id = id;
|
|
@@ -16,7 +22,7 @@ export default class {
|
|
|
16
22
|
this.exists = true;
|
|
17
23
|
this.identifier = 0;
|
|
18
24
|
this.pointerId = null;
|
|
19
|
-
this.pointerMode = pointerMode ||
|
|
25
|
+
this.pointerMode = pointerMode || POINTER_CURSOR | POINTER_CONTACT;
|
|
20
26
|
this.target = null;
|
|
21
27
|
this.button = null;
|
|
22
28
|
this._holdSent = false;
|
|
@@ -36,7 +42,7 @@ export default class {
|
|
|
36
42
|
this.movementY = 0;
|
|
37
43
|
this.x = -1;
|
|
38
44
|
this.y = -1;
|
|
39
|
-
this.isMouse =
|
|
45
|
+
this.isMouse = id === 0;
|
|
40
46
|
this.isDown = false;
|
|
41
47
|
this.isUp = true;
|
|
42
48
|
this.timeDown = 0;
|
|
@@ -98,7 +104,11 @@ export default class {
|
|
|
98
104
|
this.move(event, true);
|
|
99
105
|
// x and y are the old values here?
|
|
100
106
|
this.positionDown.setTo(this.x, this.y);
|
|
101
|
-
if (
|
|
107
|
+
if (
|
|
108
|
+
input.multiInputOverride === MOUSE_OVERRIDES_TOUCH ||
|
|
109
|
+
input.multiInputOverride === MOUSE_TOUCH_COMBINE ||
|
|
110
|
+
(input.multiInputOverride === TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0)
|
|
111
|
+
) {
|
|
102
112
|
input.x = this.x;
|
|
103
113
|
input.y = this.y;
|
|
104
114
|
input.position.setTo(this.x, this.y);
|
|
@@ -124,7 +134,11 @@ export default class {
|
|
|
124
134
|
this.dirty = false;
|
|
125
135
|
}
|
|
126
136
|
if (this._holdSent === false && this.duration >= input.holdRate) {
|
|
127
|
-
if (
|
|
137
|
+
if (
|
|
138
|
+
input.multiInputOverride === MOUSE_OVERRIDES_TOUCH ||
|
|
139
|
+
input.multiInputOverride === MOUSE_TOUCH_COMBINE ||
|
|
140
|
+
(input.multiInputOverride === TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0)
|
|
141
|
+
) {
|
|
128
142
|
input.onHold.dispatch(this);
|
|
129
143
|
}
|
|
130
144
|
this._holdSent = true;
|
|
@@ -168,7 +182,11 @@ export default class {
|
|
|
168
182
|
this.position.setTo(this.x, this.y);
|
|
169
183
|
this.circle.x = this.x;
|
|
170
184
|
this.circle.y = this.y;
|
|
171
|
-
if (
|
|
185
|
+
if (
|
|
186
|
+
input.multiInputOverride === MOUSE_OVERRIDES_TOUCH ||
|
|
187
|
+
input.multiInputOverride === MOUSE_TOUCH_COMBINE ||
|
|
188
|
+
(input.multiInputOverride === TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0)
|
|
189
|
+
) {
|
|
172
190
|
input.activePointer = this;
|
|
173
191
|
input.x = this.x;
|
|
174
192
|
input.y = this.y;
|
|
@@ -184,7 +202,13 @@ export default class {
|
|
|
184
202
|
let i = input.moveCallbacks.length;
|
|
185
203
|
while (i) {
|
|
186
204
|
i -= 1;
|
|
187
|
-
input.moveCallbacks[i].callback.call(
|
|
205
|
+
input.moveCallbacks[i].callback.call(
|
|
206
|
+
input.moveCallbacks[i].context,
|
|
207
|
+
this,
|
|
208
|
+
this.x,
|
|
209
|
+
this.y,
|
|
210
|
+
fromClick
|
|
211
|
+
);
|
|
188
212
|
}
|
|
189
213
|
// Easy out if we're dragging something and it still exists
|
|
190
214
|
if (this.targetObject !== null && this.targetObject.isDragged === true) {
|
|
@@ -212,7 +236,10 @@ export default class {
|
|
|
212
236
|
if (currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, false)) {
|
|
213
237
|
// Flag it as checked so we don't re-scan it on the next phase
|
|
214
238
|
currentNode.checked = true;
|
|
215
|
-
if (
|
|
239
|
+
if (
|
|
240
|
+
(fromClick && currentNode.checkPointerDown(this, true)) ||
|
|
241
|
+
(!fromClick && currentNode.checkPointerOver(this, true))
|
|
242
|
+
) {
|
|
216
243
|
highestRenderOrderID = currentNode.sprite.renderOrderID;
|
|
217
244
|
highestInputPriorityID = currentNode.priorityID;
|
|
218
245
|
candidateTarget = currentNode;
|
|
@@ -226,8 +253,14 @@ export default class {
|
|
|
226
253
|
// (A node that was previously checked did not request a pixel-perfect check.)
|
|
227
254
|
currentNode = this.game.input.interactiveItems.first;
|
|
228
255
|
while (currentNode) {
|
|
229
|
-
if (
|
|
230
|
-
|
|
256
|
+
if (
|
|
257
|
+
!currentNode.checked &&
|
|
258
|
+
currentNode.validForInput(highestInputPriorityID, highestRenderOrderID, true)
|
|
259
|
+
) {
|
|
260
|
+
if (
|
|
261
|
+
(fromClick && currentNode.checkPointerDown(this, false)) ||
|
|
262
|
+
(!fromClick && currentNode.checkPointerOver(this, false))
|
|
263
|
+
) {
|
|
231
264
|
highestRenderOrderID = currentNode.sprite.renderOrderID;
|
|
232
265
|
highestInputPriorityID = currentNode.priorityID;
|
|
233
266
|
candidateTarget = currentNode;
|
|
@@ -237,10 +270,15 @@ export default class {
|
|
|
237
270
|
currentNode = this.game.input.interactiveItems.next;
|
|
238
271
|
}
|
|
239
272
|
if (this.game.input.customCandidateHandler) {
|
|
240
|
-
candidateTarget = this.game.input.customCandidateHandler.call(
|
|
273
|
+
candidateTarget = this.game.input.customCandidateHandler.call(
|
|
274
|
+
this.game.input.customCandidateHandlerContext,
|
|
275
|
+
this,
|
|
276
|
+
this.interactiveCandidates,
|
|
277
|
+
candidateTarget
|
|
278
|
+
);
|
|
241
279
|
}
|
|
242
280
|
this.swapTarget(candidateTarget, false);
|
|
243
|
-
return
|
|
281
|
+
return this.targetObject !== null;
|
|
244
282
|
}
|
|
245
283
|
|
|
246
284
|
swapTarget(newTarget, silent = false) {
|
|
@@ -282,7 +320,11 @@ export default class {
|
|
|
282
320
|
return null;
|
|
283
321
|
}
|
|
284
322
|
this.timeUp = this.game.time.time;
|
|
285
|
-
if (
|
|
323
|
+
if (
|
|
324
|
+
input.multiInputOverride === MOUSE_OVERRIDES_TOUCH ||
|
|
325
|
+
input.multiInputOverride === MOUSE_TOUCH_COMBINE ||
|
|
326
|
+
(input.multiInputOverride === TOUCH_OVERRIDES_MOUSE && input.totalActivePointers === 0)
|
|
327
|
+
) {
|
|
286
328
|
input.onUp.dispatch(this, event);
|
|
287
329
|
// Was it a tap?
|
|
288
330
|
if (this.duration >= 0 && this.duration <= input.tapRate) {
|
|
@@ -324,12 +366,12 @@ export default class {
|
|
|
324
366
|
|
|
325
367
|
justPressed(duration) {
|
|
326
368
|
duration = duration || this.game.input.justPressedRate;
|
|
327
|
-
return
|
|
369
|
+
return this.isDown === true && this.timeDown + duration > this.game.time.time;
|
|
328
370
|
}
|
|
329
371
|
|
|
330
372
|
justReleased(duration) {
|
|
331
373
|
duration = duration || this.game.input.justReleasedRate;
|
|
332
|
-
return
|
|
374
|
+
return this.isUp && this.timeUp + duration > this.game.time.time;
|
|
333
375
|
}
|
|
334
376
|
|
|
335
377
|
addClickTrampoline(name, callback, callbackContext, callbackArgs) {
|
|
@@ -405,5 +447,4 @@ export default class {
|
|
|
405
447
|
get worldY() {
|
|
406
448
|
return this.y;
|
|
407
449
|
}
|
|
408
|
-
|
|
409
450
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export default class {
|
|
8
|
-
|
|
9
8
|
constructor(game) {
|
|
10
9
|
this.game = game;
|
|
11
10
|
this.enabled = true;
|
|
@@ -32,12 +31,12 @@ export default class {
|
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
const scope = this;
|
|
35
|
-
this._onTouchStart = event => scope.onTouchStart(event);
|
|
36
|
-
this._onTouchMove = event => scope.onTouchMove(event);
|
|
37
|
-
this._onTouchEnd = event => scope.onTouchEnd(event);
|
|
38
|
-
this._onTouchEnter = event => scope.onTouchEnter(event);
|
|
39
|
-
this._onTouchLeave = event => scope.onTouchLeave(event);
|
|
40
|
-
this._onTouchCancel = event => scope.onTouchCancel(event);
|
|
34
|
+
this._onTouchStart = (event) => scope.onTouchStart(event);
|
|
35
|
+
this._onTouchMove = (event) => scope.onTouchMove(event);
|
|
36
|
+
this._onTouchEnd = (event) => scope.onTouchEnd(event);
|
|
37
|
+
this._onTouchEnter = (event) => scope.onTouchEnter(event);
|
|
38
|
+
this._onTouchLeave = (event) => scope.onTouchLeave(event);
|
|
39
|
+
this._onTouchCancel = (event) => scope.onTouchCancel(event);
|
|
41
40
|
this.game.canvas.addEventListener('touchstart', this._onTouchStart, false);
|
|
42
41
|
this.game.canvas.addEventListener('touchmove', this._onTouchMove, false);
|
|
43
42
|
this.game.canvas.addEventListener('touchend', this._onTouchEnd, false);
|
|
@@ -149,5 +148,4 @@ export default class {
|
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
|
-
|
|
153
151
|
}
|