@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
|
@@ -11,7 +11,6 @@ import { PI_2 } from '../util/math';
|
|
|
11
11
|
import { renderCanvas, renderWebGL } from './sprite_util';
|
|
12
12
|
|
|
13
13
|
export default class {
|
|
14
|
-
|
|
15
14
|
constructor() {
|
|
16
15
|
this.exists = true;
|
|
17
16
|
this.renderable = false;
|
|
@@ -83,7 +82,13 @@ export default class {
|
|
|
83
82
|
this.children.splice(index, 0, child);
|
|
84
83
|
return child;
|
|
85
84
|
}
|
|
86
|
-
throw new Error(
|
|
85
|
+
throw new Error(
|
|
86
|
+
child +
|
|
87
|
+
'addChildAt: The index ' +
|
|
88
|
+
index +
|
|
89
|
+
' supplied is out of bounds ' +
|
|
90
|
+
this.children.length
|
|
91
|
+
);
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
swapChildren(child, child2) {
|
|
@@ -93,7 +98,9 @@ export default class {
|
|
|
93
98
|
const index1 = this.getChildIndex(child);
|
|
94
99
|
const index2 = this.getChildIndex(child2);
|
|
95
100
|
if (index1 < 0 || index2 < 0) {
|
|
96
|
-
throw new Error(
|
|
101
|
+
throw new Error(
|
|
102
|
+
'swapChildren: Both the supplied DisplayObjects must be a child of the caller.'
|
|
103
|
+
);
|
|
97
104
|
}
|
|
98
105
|
this.children[index1] = child2;
|
|
99
106
|
this.children[index2] = child;
|
|
@@ -118,7 +125,11 @@ export default class {
|
|
|
118
125
|
|
|
119
126
|
getChildAt(index) {
|
|
120
127
|
if (index < 0 || index >= this.children.length) {
|
|
121
|
-
throw new Error(
|
|
128
|
+
throw new Error(
|
|
129
|
+
'getChildAt: Supplied index ' +
|
|
130
|
+
index +
|
|
131
|
+
' does not exist in the child list, or the supplied DisplayObject must be a child of the caller'
|
|
132
|
+
);
|
|
122
133
|
}
|
|
123
134
|
return this.children[index];
|
|
124
135
|
}
|
|
@@ -228,7 +239,10 @@ export default class {
|
|
|
228
239
|
// Set the World values
|
|
229
240
|
this.worldAlpha = this.alpha * p.worldAlpha;
|
|
230
241
|
// this.worldPosition.set(wt.tx, wt.ty);
|
|
231
|
-
this.worldScale.set(
|
|
242
|
+
this.worldScale.set(
|
|
243
|
+
this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c),
|
|
244
|
+
this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d)
|
|
245
|
+
);
|
|
232
246
|
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
|
233
247
|
// reset the bounds each time this is called!
|
|
234
248
|
this.currentBounds = null;
|
|
@@ -243,7 +257,8 @@ export default class {
|
|
|
243
257
|
}
|
|
244
258
|
|
|
245
259
|
getBounds(targetCoordinateSpace) {
|
|
246
|
-
const isTargetCoordinateSpaceDisplayObject =
|
|
260
|
+
const isTargetCoordinateSpaceDisplayObject =
|
|
261
|
+
targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
|
|
247
262
|
let isTargetCoordinateSpaceThisOrParent = true;
|
|
248
263
|
if (!isTargetCoordinateSpaceDisplayObject) {
|
|
249
264
|
targetCoordinateSpace = this;
|
|
@@ -274,12 +289,12 @@ export default class {
|
|
|
274
289
|
if (child.visible) {
|
|
275
290
|
childVisible = true;
|
|
276
291
|
childBounds = this.children[i].getBounds();
|
|
277
|
-
minX =
|
|
278
|
-
minY =
|
|
292
|
+
minX = minX < childBounds.x ? minX : childBounds.x;
|
|
293
|
+
minY = minY < childBounds.y ? minY : childBounds.y;
|
|
279
294
|
childMaxX = childBounds.width + childBounds.x;
|
|
280
295
|
childMaxY = childBounds.height + childBounds.y;
|
|
281
|
-
maxX =
|
|
282
|
-
maxY =
|
|
296
|
+
maxX = maxX > childMaxX ? maxX : childMaxX;
|
|
297
|
+
maxY = maxY > childMaxY ? maxY : childMaxY;
|
|
283
298
|
}
|
|
284
299
|
}
|
|
285
300
|
let bounds = this.cachedBounds;
|
|
@@ -542,19 +557,19 @@ export default class {
|
|
|
542
557
|
}
|
|
543
558
|
|
|
544
559
|
get centerX() {
|
|
545
|
-
return
|
|
560
|
+
return this.x - this.offsetX + this.width * 0.5;
|
|
546
561
|
}
|
|
547
562
|
|
|
548
563
|
set centerX(value) {
|
|
549
|
-
this.x =
|
|
564
|
+
this.x = value + this.offsetX - this.width * 0.5;
|
|
550
565
|
}
|
|
551
566
|
|
|
552
567
|
get centerY() {
|
|
553
|
-
return
|
|
568
|
+
return this.y - this.offsetY + this.height * 0.5;
|
|
554
569
|
}
|
|
555
570
|
|
|
556
571
|
set centerY(value) {
|
|
557
|
-
this.y =
|
|
572
|
+
this.y = value + this.offsetY - this.height * 0.5;
|
|
558
573
|
}
|
|
559
574
|
|
|
560
575
|
get left() {
|
|
@@ -566,11 +581,11 @@ export default class {
|
|
|
566
581
|
}
|
|
567
582
|
|
|
568
583
|
get right() {
|
|
569
|
-
return
|
|
584
|
+
return this.x + this.width - this.offsetX;
|
|
570
585
|
}
|
|
571
586
|
|
|
572
587
|
set right(value) {
|
|
573
|
-
this.x = value -
|
|
588
|
+
this.x = value - this.width + this.offsetX;
|
|
574
589
|
}
|
|
575
590
|
|
|
576
591
|
get top() {
|
|
@@ -582,11 +597,10 @@ export default class {
|
|
|
582
597
|
}
|
|
583
598
|
|
|
584
599
|
get bottom() {
|
|
585
|
-
return
|
|
600
|
+
return this.y + this.height - this.offsetY;
|
|
586
601
|
}
|
|
587
602
|
|
|
588
603
|
set bottom(value) {
|
|
589
|
-
this.y = value -
|
|
604
|
+
this.y = value - this.height + this.offsetY;
|
|
590
605
|
}
|
|
591
|
-
|
|
592
606
|
}
|
|
@@ -16,13 +16,23 @@ import CanvasBuffer from './canvas/buffer';
|
|
|
16
16
|
import { textureFromCanvas } from './webgl/texture_util';
|
|
17
17
|
import { renderGraphics as renderCanvasGraphics } from './canvas/graphics';
|
|
18
18
|
import { renderGraphics as renderWebGLGraphics } from './webgl/graphics';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
renderCanvas as renderSpriteCanvas,
|
|
21
|
+
renderWebGL as renderSpriteWebGL,
|
|
22
|
+
} from './sprite_util';
|
|
20
23
|
import { getEmptyRectangle } from '../geom/util/rectangle';
|
|
21
24
|
import { getIdentityMatrix } from '../geom/util/matrix';
|
|
22
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
BLEND_NORMAL,
|
|
27
|
+
GRAPHICS,
|
|
28
|
+
GEOM_POLYGON,
|
|
29
|
+
GEOM_CIRCLE,
|
|
30
|
+
GEOM_ELLIPSE,
|
|
31
|
+
GEOM_RECTANGLE,
|
|
32
|
+
GEOM_ROUNDED_RECTANGLE,
|
|
33
|
+
} from '../core/const';
|
|
23
34
|
|
|
24
35
|
export default class extends DisplayObject {
|
|
25
|
-
|
|
26
36
|
constructor(game, x = 0, y = 0) {
|
|
27
37
|
super();
|
|
28
38
|
this.game = game;
|
|
@@ -33,7 +43,7 @@ export default class extends DisplayObject {
|
|
|
33
43
|
this.lineWidth = 0;
|
|
34
44
|
this.lineColor = 0;
|
|
35
45
|
this.graphicsData = [];
|
|
36
|
-
this.tint =
|
|
46
|
+
this.tint = 0xffffff;
|
|
37
47
|
this.blendMode = BLEND_NORMAL;
|
|
38
48
|
this.currentPath = null;
|
|
39
49
|
this._webGL = [];
|
|
@@ -55,7 +65,7 @@ export default class extends DisplayObject {
|
|
|
55
65
|
lineStyle(lineWidth = 0, color = 0, alpha = 1) {
|
|
56
66
|
this.lineWidth = lineWidth || 0;
|
|
57
67
|
this.lineColor = color || 0;
|
|
58
|
-
this.lineAlpha =
|
|
68
|
+
this.lineAlpha = alpha === undefined ? 1 : alpha;
|
|
59
69
|
if (this.currentPath) {
|
|
60
70
|
if (this.currentPath.shape.points.length) {
|
|
61
71
|
// halfway through a line? start a new one!
|
|
@@ -105,9 +115,9 @@ export default class extends DisplayObject {
|
|
|
105
115
|
let j = 0;
|
|
106
116
|
for (let i = 1; i <= n; i += 1) {
|
|
107
117
|
j = i / n;
|
|
108
|
-
xa = fromX + (
|
|
109
|
-
ya = fromY + (
|
|
110
|
-
points.push(xa + (
|
|
118
|
+
xa = fromX + (cpX - fromX) * j;
|
|
119
|
+
ya = fromY + (cpY - fromY) * j;
|
|
120
|
+
points.push(xa + (cpX + (toX - cpX) * j - xa) * j, ya + (cpY + (toY - cpY) * j - ya) * j);
|
|
111
121
|
}
|
|
112
122
|
this.dirty = true;
|
|
113
123
|
this._boundsDirty = true;
|
|
@@ -134,12 +144,15 @@ export default class extends DisplayObject {
|
|
|
134
144
|
let j = 0;
|
|
135
145
|
for (let i = 1; i <= n; i += 1) {
|
|
136
146
|
j = i / n;
|
|
137
|
-
dt =
|
|
147
|
+
dt = 1 - j;
|
|
138
148
|
dt2 = dt * dt;
|
|
139
149
|
dt3 = dt2 * dt;
|
|
140
150
|
t2 = j * j;
|
|
141
151
|
t3 = t2 * j;
|
|
142
|
-
points.push(
|
|
152
|
+
points.push(
|
|
153
|
+
dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX,
|
|
154
|
+
dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY
|
|
155
|
+
);
|
|
143
156
|
}
|
|
144
157
|
this.dirty = true;
|
|
145
158
|
this._boundsDirty = true;
|
|
@@ -170,10 +183,10 @@ export default class extends DisplayObject {
|
|
|
170
183
|
const dd = a1 * a1 + b1 * b1;
|
|
171
184
|
const cc = a2 * a2 + b2 * b2;
|
|
172
185
|
const tt = a1 * a2 + b1 * b2;
|
|
173
|
-
const k1 = radius * Math.sqrt(dd) / mm;
|
|
174
|
-
const k2 = radius * Math.sqrt(cc) / mm;
|
|
175
|
-
const j1 = k1 * tt / dd;
|
|
176
|
-
const j2 = k2 * tt / cc;
|
|
186
|
+
const k1 = (radius * Math.sqrt(dd)) / mm;
|
|
187
|
+
const k2 = (radius * Math.sqrt(cc)) / mm;
|
|
188
|
+
const j1 = (k1 * tt) / dd;
|
|
189
|
+
const j2 = (k2 * tt) / cc;
|
|
177
190
|
const cx = k1 * b2 + k2 * b1;
|
|
178
191
|
const cy = k1 * a2 + k2 * a1;
|
|
179
192
|
const px = b1 * (k2 + j1);
|
|
@@ -199,7 +212,7 @@ export default class extends DisplayObject {
|
|
|
199
212
|
} else if (anticlockwise && startAngle <= endAngle) {
|
|
200
213
|
startAngle += Math.PI * 2;
|
|
201
214
|
}
|
|
202
|
-
const sweep = anticlockwise ? (startAngle - endAngle) * -1 :
|
|
215
|
+
const sweep = anticlockwise ? (startAngle - endAngle) * -1 : endAngle - startAngle;
|
|
203
216
|
const segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * segments;
|
|
204
217
|
// Sweep check - moved here because we don't want to do the moveTo below if the arc fails
|
|
205
218
|
if (sweep === 0) {
|
|
@@ -222,10 +235,13 @@ export default class extends DisplayObject {
|
|
|
222
235
|
const remainder = (segMinus % 1) / segMinus;
|
|
223
236
|
for (let i = 0; i <= segMinus; i += 1) {
|
|
224
237
|
const real = i + remainder * i;
|
|
225
|
-
const angle =
|
|
238
|
+
const angle = theta + startAngle + theta2 * real;
|
|
226
239
|
const c = Math.cos(angle);
|
|
227
240
|
const s = -Math.sin(angle);
|
|
228
|
-
points.push(
|
|
241
|
+
points.push(
|
|
242
|
+
(cTheta * c + sTheta * s) * radius + cx,
|
|
243
|
+
(cTheta * -s + sTheta * c) * radius + cy
|
|
244
|
+
);
|
|
229
245
|
}
|
|
230
246
|
this.dirty = true;
|
|
231
247
|
this._boundsDirty = true;
|
|
@@ -235,7 +251,7 @@ export default class extends DisplayObject {
|
|
|
235
251
|
beginFill(color = 0, alpha = 1) {
|
|
236
252
|
this.filling = true;
|
|
237
253
|
this.fillColor = color || 0;
|
|
238
|
-
this.fillAlpha =
|
|
254
|
+
this.fillAlpha = alpha === undefined ? 1 : alpha;
|
|
239
255
|
if (this.currentPath) {
|
|
240
256
|
if (this.currentPath.shape.points.length <= 2) {
|
|
241
257
|
this.currentPath.fill = this.filling;
|
|
@@ -336,7 +352,8 @@ export default class extends DisplayObject {
|
|
|
336
352
|
// check blend mode
|
|
337
353
|
if (this.blendMode !== renderSession.spriteBatch.currentBlendMode) {
|
|
338
354
|
renderSession.spriteBatch.currentBlendMode = this.blendMode;
|
|
339
|
-
const blendModeWebGL =
|
|
355
|
+
const blendModeWebGL =
|
|
356
|
+
window.PhaserRegistry.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
|
340
357
|
renderSession.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
|
341
358
|
}
|
|
342
359
|
// check if the webgl graphic needs to be updated
|
|
@@ -390,21 +407,22 @@ export default class extends DisplayObject {
|
|
|
390
407
|
const transform = this.worldTransform;
|
|
391
408
|
if (this.blendMode !== renderSession.currentBlendMode) {
|
|
392
409
|
renderSession.currentBlendMode = this.blendMode;
|
|
393
|
-
context.globalCompositeOperation =
|
|
410
|
+
context.globalCompositeOperation =
|
|
411
|
+
window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
|
|
394
412
|
}
|
|
395
413
|
if (this._mask) {
|
|
396
414
|
renderSession.maskManager.pushMask(this._mask, renderSession);
|
|
397
415
|
}
|
|
398
416
|
const resolution = renderSession.resolution;
|
|
399
|
-
const tx =
|
|
400
|
-
const ty =
|
|
417
|
+
const tx = transform.tx * renderSession.resolution + renderSession.shakeX;
|
|
418
|
+
const ty = transform.ty * renderSession.resolution + renderSession.shakeY;
|
|
401
419
|
context.setTransform(
|
|
402
420
|
transform.a * resolution,
|
|
403
421
|
transform.b * resolution,
|
|
404
422
|
transform.c * resolution,
|
|
405
423
|
transform.d * resolution,
|
|
406
424
|
tx,
|
|
407
|
-
ty
|
|
425
|
+
ty
|
|
408
426
|
);
|
|
409
427
|
renderCanvasGraphics(this, context);
|
|
410
428
|
// simple render children!
|
|
@@ -574,9 +592,9 @@ export default class extends DisplayObject {
|
|
|
574
592
|
}
|
|
575
593
|
const padding = this.boundsPadding;
|
|
576
594
|
this._localBounds.x = minX - padding;
|
|
577
|
-
this._localBounds.width =
|
|
595
|
+
this._localBounds.width = maxX - minX + padding * 2;
|
|
578
596
|
this._localBounds.y = minY - padding;
|
|
579
|
-
this._localBounds.height =
|
|
597
|
+
this._localBounds.height = maxY - minY + padding * 2;
|
|
580
598
|
}
|
|
581
599
|
|
|
582
600
|
generateCachedSprite() {
|
|
@@ -639,7 +657,15 @@ export default class extends DisplayObject {
|
|
|
639
657
|
shape = shape.clone();
|
|
640
658
|
shape.flatten();
|
|
641
659
|
}
|
|
642
|
-
const data = new GraphicsData(
|
|
660
|
+
const data = new GraphicsData(
|
|
661
|
+
this.lineWidth,
|
|
662
|
+
this.lineColor,
|
|
663
|
+
this.lineAlpha,
|
|
664
|
+
this.fillColor,
|
|
665
|
+
this.fillAlpha,
|
|
666
|
+
this.filling,
|
|
667
|
+
shape
|
|
668
|
+
);
|
|
643
669
|
this.graphicsData.push(data);
|
|
644
670
|
if (data.type === GEOM_POLYGON) {
|
|
645
671
|
data.shape.closed = this.filling;
|
|
@@ -719,5 +745,4 @@ export default class extends DisplayObject {
|
|
|
719
745
|
}
|
|
720
746
|
}
|
|
721
747
|
}
|
|
722
|
-
|
|
723
748
|
}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { clone } from './graphics_data_util';
|
|
7
7
|
|
|
8
8
|
export default class {
|
|
9
|
-
|
|
10
9
|
constructor(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape) {
|
|
11
10
|
this.lineWidth = lineWidth;
|
|
12
11
|
this.lineColor = lineColor;
|
|
@@ -23,5 +22,4 @@ export default class {
|
|
|
23
22
|
clone() {
|
|
24
23
|
return clone(this);
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
}
|
|
@@ -11,5 +11,13 @@ import GraphicsData from './graphics_data';
|
|
|
11
11
|
* @returns {object} TBD
|
|
12
12
|
*/
|
|
13
13
|
export function clone(source) {
|
|
14
|
-
return new GraphicsData(
|
|
14
|
+
return new GraphicsData(
|
|
15
|
+
source.lineWidth,
|
|
16
|
+
source.lineColor,
|
|
17
|
+
source.lineAlpha,
|
|
18
|
+
source.fillColor,
|
|
19
|
+
source.fillAlpha,
|
|
20
|
+
source.fill,
|
|
21
|
+
source.shape
|
|
22
|
+
);
|
|
15
23
|
}
|
|
@@ -12,7 +12,6 @@ export const SORT_ASCENDING = -1;
|
|
|
12
12
|
export const SORT_DESCENDING = 1;
|
|
13
13
|
|
|
14
14
|
export default class extends DisplayObject {
|
|
15
|
-
|
|
16
15
|
constructor(game, parent = null, name = 'group', addToStage = false) {
|
|
17
16
|
super();
|
|
18
17
|
this.game = game;
|
|
@@ -219,9 +218,7 @@ export default class extends DisplayObject {
|
|
|
219
218
|
if (destroy && removed) {
|
|
220
219
|
removed.destroy(true, destroyTexture);
|
|
221
220
|
}
|
|
222
|
-
}
|
|
223
|
-
while (this.children.length > 0);
|
|
221
|
+
} while (this.children.length > 0);
|
|
224
222
|
this.cursor = null;
|
|
225
223
|
}
|
|
226
|
-
|
|
227
224
|
}
|
|
@@ -13,7 +13,6 @@ import { IMAGE, PENDING_ATLAS, BLEND_NORMAL, SCALE_NEAREST } from '../core/const
|
|
|
13
13
|
import { setTexture, getBounds, getLocalBounds, renderCanvas, renderWebGL } from './sprite_util';
|
|
14
14
|
|
|
15
15
|
export default class extends DisplayObject {
|
|
16
|
-
|
|
17
16
|
constructor(game, x, y, key, frame) {
|
|
18
17
|
super();
|
|
19
18
|
this.game = game;
|
|
@@ -24,7 +23,7 @@ export default class extends DisplayObject {
|
|
|
24
23
|
this.data = {};
|
|
25
24
|
this._width = 0;
|
|
26
25
|
this._height = 0;
|
|
27
|
-
this.tint =
|
|
26
|
+
this.tint = 0xffffff;
|
|
28
27
|
this.cachedTint = -1;
|
|
29
28
|
this.tintedTexture = null;
|
|
30
29
|
this.blendMode = BLEND_NORMAL;
|
|
@@ -44,7 +43,7 @@ export default class extends DisplayObject {
|
|
|
44
43
|
this.key = null;
|
|
45
44
|
this.data = null;
|
|
46
45
|
this.texture = null;
|
|
47
|
-
this.tint =
|
|
46
|
+
this.tint = 0xffffff;
|
|
48
47
|
this.cachedTint = -1;
|
|
49
48
|
this.tintedTexture = null;
|
|
50
49
|
this.shader = null;
|
|
@@ -284,5 +283,4 @@ export default class extends DisplayObject {
|
|
|
284
283
|
renderCanvas(renderSession, matrix = null) {
|
|
285
284
|
renderCanvas(this, renderSession, matrix);
|
|
286
285
|
}
|
|
287
|
-
|
|
288
286
|
}
|
|
@@ -183,7 +183,13 @@ export function renderWebGL(target, renderSession, matrix) {
|
|
|
183
183
|
*/
|
|
184
184
|
export function renderCanvas(target, renderSession, matrix) {
|
|
185
185
|
// If the sprite is not visible or the alpha is 0 then no need to render this element
|
|
186
|
-
if (
|
|
186
|
+
if (
|
|
187
|
+
!target.visible ||
|
|
188
|
+
target.alpha === 0 ||
|
|
189
|
+
!target.renderable ||
|
|
190
|
+
target.texture.crop.width <= 0 ||
|
|
191
|
+
target.texture.crop.height <= 0
|
|
192
|
+
) {
|
|
187
193
|
return;
|
|
188
194
|
}
|
|
189
195
|
let wt = target.worldTransform;
|
|
@@ -193,7 +199,8 @@ export function renderCanvas(target, renderSession, matrix) {
|
|
|
193
199
|
}
|
|
194
200
|
if (target.blendMode !== renderSession.currentBlendMode) {
|
|
195
201
|
renderSession.currentBlendMode = target.blendMode;
|
|
196
|
-
renderSession.context.globalCompositeOperation =
|
|
202
|
+
renderSession.context.globalCompositeOperation =
|
|
203
|
+
window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
|
|
197
204
|
}
|
|
198
205
|
if (target._mask) {
|
|
199
206
|
renderSession.maskManager.pushMask(target._mask, renderSession);
|
|
@@ -204,15 +211,23 @@ export function renderCanvas(target, renderSession, matrix) {
|
|
|
204
211
|
renderSession.context.globalAlpha = target.worldAlpha;
|
|
205
212
|
|
|
206
213
|
// If smoothingEnabled is supported and we need to change the smoothing property for this texture
|
|
207
|
-
if (
|
|
214
|
+
if (
|
|
215
|
+
renderSession.smoothProperty &&
|
|
216
|
+
renderSession.scaleMode !== target.texture.baseTexture.scaleMode
|
|
217
|
+
) {
|
|
208
218
|
renderSession.scaleMode = target.texture.baseTexture.scaleMode;
|
|
209
|
-
renderSession.context[renderSession.smoothProperty] =
|
|
219
|
+
renderSession.context[renderSession.smoothProperty] =
|
|
220
|
+
renderSession.scaleMode === SCALE_LINEAR;
|
|
210
221
|
}
|
|
211
222
|
// If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions
|
|
212
|
-
let dx =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
223
|
+
let dx = target.texture.trim
|
|
224
|
+
? target.texture.trim.x - target.anchor.x * target.texture.trim.width
|
|
225
|
+
: target.anchor.x * -target.texture.frame.width;
|
|
226
|
+
let dy = target.texture.trim
|
|
227
|
+
? target.texture.trim.y - target.anchor.y * target.texture.trim.height
|
|
228
|
+
: target.anchor.y * -target.texture.frame.height;
|
|
229
|
+
const tx = wt.tx * renderSession.resolution + renderSession.shakeX;
|
|
230
|
+
const ty = wt.ty * renderSession.resolution + renderSession.shakeY;
|
|
216
231
|
// Allow for pixel rounding
|
|
217
232
|
if (renderSession.roundPixels) {
|
|
218
233
|
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx | 0, ty | 0);
|
|
@@ -225,20 +240,40 @@ export function renderCanvas(target, renderSession, matrix) {
|
|
|
225
240
|
let ch = target.texture.crop.height;
|
|
226
241
|
dx /= resolution;
|
|
227
242
|
dy /= resolution;
|
|
228
|
-
if (target.tint !==
|
|
243
|
+
if (target.tint !== 0xffffff) {
|
|
229
244
|
if (target.texture.requiresReTint || target.cachedTint !== target.tint) {
|
|
230
245
|
target.tintedTexture = getTintedTexture(target, target.tint);
|
|
231
246
|
target.cachedTint = target.tint;
|
|
232
247
|
target.texture.requiresReTint = false;
|
|
233
248
|
}
|
|
234
|
-
renderSession.context.drawImage(
|
|
249
|
+
renderSession.context.drawImage(
|
|
250
|
+
target.tintedTexture,
|
|
251
|
+
0,
|
|
252
|
+
0,
|
|
253
|
+
cw,
|
|
254
|
+
ch,
|
|
255
|
+
dx,
|
|
256
|
+
dy,
|
|
257
|
+
cw / resolution,
|
|
258
|
+
ch / resolution
|
|
259
|
+
);
|
|
235
260
|
} else {
|
|
236
261
|
const cx = target.texture.crop.x;
|
|
237
262
|
const cy = target.texture.crop.y;
|
|
238
263
|
// https://github.com/photonstorm/phaser-ce/pull/61
|
|
239
264
|
cw = Math.floor(cw);
|
|
240
265
|
ch = Math.floor(ch);
|
|
241
|
-
renderSession.context.drawImage(
|
|
266
|
+
renderSession.context.drawImage(
|
|
267
|
+
target.texture.baseTexture.source,
|
|
268
|
+
cx,
|
|
269
|
+
cy,
|
|
270
|
+
cw,
|
|
271
|
+
ch,
|
|
272
|
+
dx,
|
|
273
|
+
dy,
|
|
274
|
+
cw / resolution,
|
|
275
|
+
ch / resolution
|
|
276
|
+
);
|
|
242
277
|
}
|
|
243
278
|
}
|
|
244
279
|
for (let i = 0; i < target.children.length; i += 1) {
|