@vpmedia/phaser 1.103.0 → 1.105.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/dist/index.js +997 -403
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -11
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +20 -10
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +3 -3
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +68 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts +10 -10
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +6 -5
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +49 -158
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +8 -7
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts +27 -48
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +11 -58
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts +4 -14
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +50 -3
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +66 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +64 -20
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +26 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +18 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +53 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +19 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +56 -28
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +2 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +77 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +25 -9
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +9 -8
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +2 -2
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +58 -10
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +28 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +10 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +7 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +32 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +30 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -12
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +38 -14
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +30 -5
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +8 -4
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +35 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +24 -8
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +6 -2
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +18 -5
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -3
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +9 -9
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +82 -23
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +42 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +11 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +24 -9
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +36 -13
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +86 -66
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +8 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +5 -2
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +10 -10
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +17 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +7 -2
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +11 -10
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +11 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +12 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +25 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +35 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +6 -6
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +11 -10
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +6 -5
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +14 -14
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +13 -12
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts +19 -19
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +6 -6
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +20 -20
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +9 -7
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +19 -19
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +2 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +17 -15
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts +51 -142
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/phaser/core/animation.ts +41 -18
- package/src/phaser/core/animation_manager.ts +21 -12
- package/src/phaser/core/animation_parser.ts +11 -3
- package/src/phaser/core/array_set.ts +8 -8
- package/src/phaser/core/cache.ts +75 -60
- package/src/phaser/core/device.ts +23 -1
- package/src/phaser/core/device_util.ts +10 -10
- package/src/phaser/core/dom.ts +5 -5
- package/src/phaser/core/event_manager.ts +52 -177
- package/src/phaser/core/factory.ts +25 -17
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -74
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +40 -11
- package/src/phaser/core/input.ts +68 -17
- package/src/phaser/core/input_handler.ts +81 -45
- package/src/phaser/core/input_mouse.ts +42 -13
- package/src/phaser/core/input_mspointer.ts +24 -9
- package/src/phaser/core/input_pointer.ts +55 -12
- package/src/phaser/core/input_touch.ts +26 -9
- package/src/phaser/core/loader.ts +97 -42
- package/src/phaser/core/loader_parser.ts +6 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -27
- package/src/phaser/core/scene.ts +3 -2
- package/src/phaser/core/scene_manager.ts +26 -11
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +72 -26
- package/src/phaser/core/sound_manager.ts +31 -13
- package/src/phaser/core/sound_sprite.ts +10 -5
- package/src/phaser/core/stage.ts +8 -4
- package/src/phaser/core/time.ts +33 -7
- package/src/phaser/core/timer.ts +40 -14
- package/src/phaser/core/timer_event.ts +23 -14
- package/src/phaser/core/tween.ts +43 -23
- package/src/phaser/core/tween_data.ts +31 -7
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -7
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -18
- package/src/phaser/display/button.ts +24 -23
- package/src/phaser/display/canvas/buffer.ts +6 -3
- package/src/phaser/display/canvas/graphics.ts +3 -4
- package/src/phaser/display/canvas/masker.ts +2 -3
- package/src/phaser/display/canvas/pool.ts +3 -4
- package/src/phaser/display/canvas/renderer.ts +19 -7
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +9 -9
- package/src/phaser/display/display_object.ts +120 -61
- package/src/phaser/display/graphics.ts +56 -25
- package/src/phaser/display/graphics_data.ts +11 -2
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -14
- package/src/phaser/display/image.ts +37 -19
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +5 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -2
- package/src/phaser/display/webgl/base_texture.ts +14 -3
- package/src/phaser/display/webgl/blend_manager.ts +5 -3
- package/src/phaser/display/webgl/earcut.ts +27 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -4
- package/src/phaser/display/webgl/filter_manager.ts +5 -2
- package/src/phaser/display/webgl/filter_texture.ts +7 -3
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -2
- package/src/phaser/display/webgl/renderer.ts +24 -7
- package/src/phaser/display/webgl/shader/complex.ts +7 -2
- package/src/phaser/display/webgl/shader/fast.ts +8 -2
- package/src/phaser/display/webgl/shader/normal.ts +12 -2
- package/src/phaser/display/webgl/shader/primitive.ts +7 -2
- package/src/phaser/display/webgl/shader/strip.ts +7 -2
- package/src/phaser/display/webgl/shader_manager.ts +13 -3
- package/src/phaser/display/webgl/sprite_batch.ts +20 -4
- package/src/phaser/display/webgl/stencil_manager.ts +8 -5
- package/src/phaser/display/webgl/texture.ts +35 -4
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +6 -6
- package/src/phaser/geom/circle.ts +10 -10
- package/src/phaser/geom/ellipse.ts +6 -6
- package/src/phaser/geom/line.ts +14 -14
- package/src/phaser/geom/matrix.ts +12 -12
- package/src/phaser/geom/point.ts +19 -19
- package/src/phaser/geom/polygon.ts +5 -5
- package/src/phaser/geom/rectangle.ts +21 -21
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +5 -5
- package/src/phaser/geom/util/matrix.ts +1 -1
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +15 -15
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.ts +65 -151
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Matrix } from '../geom/matrix.js';
|
|
3
2
|
import { Point } from '../geom/point.js';
|
|
4
3
|
import { Rectangle } from '../geom/rectangle.js';
|
|
@@ -7,11 +6,67 @@ import { PI_2 } from '../util/math.js';
|
|
|
7
6
|
import { renderCanvas, renderWebGL } from './sprite_util.js';
|
|
8
7
|
|
|
9
8
|
export class DisplayObject {
|
|
9
|
+
/** @type {boolean} */
|
|
10
|
+
exists = true;
|
|
11
|
+
/** @type {boolean} */
|
|
12
|
+
renderable = false;
|
|
13
|
+
/** @type {boolean} */
|
|
14
|
+
visible = true;
|
|
15
|
+
position!: Point;
|
|
16
|
+
scale!: Point;
|
|
17
|
+
pivot!: Point;
|
|
18
|
+
anchor!: Point;
|
|
19
|
+
/** @type {number} */
|
|
20
|
+
rotation = 0;
|
|
21
|
+
/** @type {number} */
|
|
22
|
+
alpha = 1;
|
|
23
|
+
/** @type {Rectangle} */
|
|
24
|
+
hitArea = null;
|
|
25
|
+
/** @type {DisplayObject} */
|
|
26
|
+
parent = null;
|
|
27
|
+
/** @type {number} */
|
|
28
|
+
worldAlpha = 1;
|
|
29
|
+
worldTransform!: Matrix;
|
|
30
|
+
worldScale!: Point;
|
|
31
|
+
/** @type {Rectangle} */
|
|
32
|
+
filterArea = null;
|
|
33
|
+
/** @type {number} */
|
|
34
|
+
_sr = 0;
|
|
35
|
+
/** @type {number} */
|
|
36
|
+
_cr = 1;
|
|
37
|
+
cachedBounds!: Rectangle;
|
|
38
|
+
/** @type {Rectangle} */
|
|
39
|
+
currentBounds = null;
|
|
40
|
+
/** @type {import('./graphics.js').Graphics} */
|
|
41
|
+
_mask = null;
|
|
42
|
+
/** @type {object[]} */
|
|
43
|
+
_filters = null;
|
|
44
|
+
/** @type {object} */
|
|
45
|
+
_filterBlock = null;
|
|
46
|
+
children!: any[];
|
|
47
|
+
/** @type {boolean} */
|
|
48
|
+
ignoreChildInput = false;
|
|
49
|
+
/** @type {string | null} */
|
|
50
|
+
name = null;
|
|
51
|
+
/** @type {object | null} */
|
|
52
|
+
data = null;
|
|
53
|
+
game!: import('../core/game.js').Game;
|
|
54
|
+
type!: number;
|
|
55
|
+
_cachedSprite!: any;
|
|
56
|
+
rotationCache!: any;
|
|
57
|
+
worldRotation!: any;
|
|
58
|
+
transformCallback!: any;
|
|
59
|
+
transformCallbackContext!: any;
|
|
60
|
+
_width!: any;
|
|
61
|
+
_height!: any;
|
|
62
|
+
z!: any;
|
|
63
|
+
events!: any;
|
|
64
|
+
renderOrderID!: any;
|
|
10
65
|
/**
|
|
11
66
|
* Creates a new DisplayObject instance.
|
|
12
67
|
* @param {import('../core/game.js').Game} game - The game instance this display object belongs to.
|
|
13
68
|
*/
|
|
14
|
-
constructor(game) {
|
|
69
|
+
constructor(game: import('../core/game.js').Game) {
|
|
15
70
|
/** @type {boolean} */
|
|
16
71
|
this.exists = true;
|
|
17
72
|
/** @type {boolean} */
|
|
@@ -38,10 +93,10 @@ export class DisplayObject {
|
|
|
38
93
|
this.worldAlpha = 1;
|
|
39
94
|
/** @type {Matrix} */
|
|
40
95
|
this.worldTransform = new Matrix();
|
|
41
|
-
//
|
|
96
|
+
// This.worldPosition = new Point(0, 0);
|
|
42
97
|
/** @type {Point} */
|
|
43
98
|
this.worldScale = new Point(1, 1);
|
|
44
|
-
//
|
|
99
|
+
// This.worldRotation = 0;
|
|
45
100
|
/** @type {Rectangle} */
|
|
46
101
|
this.filterArea = null;
|
|
47
102
|
/** @type {number} */
|
|
@@ -86,7 +141,7 @@ export class DisplayObject {
|
|
|
86
141
|
this.visible = false;
|
|
87
142
|
// TODO: investigate how to clean up properly object references without breaking delayed tween cleanups.
|
|
88
143
|
/*
|
|
89
|
-
|
|
144
|
+
This.position = null;
|
|
90
145
|
this.scale = null;
|
|
91
146
|
this.pivot = null;
|
|
92
147
|
this.anchor = null;
|
|
@@ -94,7 +149,7 @@ export class DisplayObject {
|
|
|
94
149
|
this.hitArea = null;
|
|
95
150
|
this.parent = null;
|
|
96
151
|
this.worldTransform = null;
|
|
97
|
-
//
|
|
152
|
+
// This.worldPosition = null;
|
|
98
153
|
this.worldScale = null;
|
|
99
154
|
this.filterArea = null;
|
|
100
155
|
this.cachedBounds = null;
|
|
@@ -108,7 +163,7 @@ export class DisplayObject {
|
|
|
108
163
|
* @param {DisplayObject} child - The child display object to add.
|
|
109
164
|
* @returns {DisplayObject} The added child display object.
|
|
110
165
|
*/
|
|
111
|
-
addChild(child) {
|
|
166
|
+
addChild(child: DisplayObject) {
|
|
112
167
|
return this.addChildAt(child, this.children.length);
|
|
113
168
|
}
|
|
114
169
|
|
|
@@ -119,7 +174,7 @@ export class DisplayObject {
|
|
|
119
174
|
* @returns {DisplayObject} The added child display object.
|
|
120
175
|
* @throws {Error} If the index is out of bounds.
|
|
121
176
|
*/
|
|
122
|
-
addChildAt(child, index) {
|
|
177
|
+
addChildAt(child: DisplayObject, index: number) {
|
|
123
178
|
if (index >= 0 && index <= this.children.length) {
|
|
124
179
|
if (child.parent) {
|
|
125
180
|
child.parent.removeChild(child);
|
|
@@ -137,7 +192,7 @@ export class DisplayObject {
|
|
|
137
192
|
* @param {DisplayObject} child2 - The second child display object.
|
|
138
193
|
* @throws {Error} If either child is not a child of this container.
|
|
139
194
|
*/
|
|
140
|
-
swapChildren(child, child2) {
|
|
195
|
+
swapChildren(child: DisplayObject, child2: DisplayObject) {
|
|
141
196
|
if (child === child2) {
|
|
142
197
|
return;
|
|
143
198
|
}
|
|
@@ -156,7 +211,7 @@ export class DisplayObject {
|
|
|
156
211
|
* @returns {number} The index of the child in the children list.
|
|
157
212
|
* @throws {Error} If the child is not a child of this container.
|
|
158
213
|
*/
|
|
159
|
-
getChildIndex(child) {
|
|
214
|
+
getChildIndex(child: DisplayObject) {
|
|
160
215
|
const index = this.children.indexOf(child);
|
|
161
216
|
if (index === -1) {
|
|
162
217
|
throw new Error('The supplied DisplayObject must be a child of the caller');
|
|
@@ -170,13 +225,13 @@ export class DisplayObject {
|
|
|
170
225
|
* @param {number} index - The new index for the child.
|
|
171
226
|
* @throws {Error} If the index is out of bounds.
|
|
172
227
|
*/
|
|
173
|
-
setChildIndex(child, index) {
|
|
228
|
+
setChildIndex(child: DisplayObject, index: number) {
|
|
174
229
|
if (index < 0 || index >= this.children.length) {
|
|
175
230
|
throw new Error('The supplied index is out of bounds');
|
|
176
231
|
}
|
|
177
232
|
const currentIndex = this.getChildIndex(child);
|
|
178
|
-
this.children.splice(currentIndex, 1); //
|
|
179
|
-
this.children.splice(index, 0, child); //
|
|
233
|
+
this.children.splice(currentIndex, 1); // Remove from old position
|
|
234
|
+
this.children.splice(index, 0, child); // Add at new position
|
|
180
235
|
}
|
|
181
236
|
|
|
182
237
|
/**
|
|
@@ -185,7 +240,7 @@ export class DisplayObject {
|
|
|
185
240
|
* @returns {DisplayObject} The child display object at the specified index.
|
|
186
241
|
* @throws {Error} If the index is out of bounds.
|
|
187
242
|
*/
|
|
188
|
-
getChildAt(index) {
|
|
243
|
+
getChildAt(index: number) {
|
|
189
244
|
if (index < 0 || index >= this.children.length) {
|
|
190
245
|
throw new Error(
|
|
191
246
|
`getChildAt: Supplied index ${
|
|
@@ -201,7 +256,7 @@ export class DisplayObject {
|
|
|
201
256
|
* @param {DisplayObject} child - The child display object to remove.
|
|
202
257
|
* @returns {DisplayObject} The removed child display object.
|
|
203
258
|
*/
|
|
204
|
-
removeChild(child) {
|
|
259
|
+
removeChild(child: DisplayObject) {
|
|
205
260
|
const index = this.children.indexOf(child);
|
|
206
261
|
if (index === -1) {
|
|
207
262
|
return null;
|
|
@@ -214,7 +269,7 @@ export class DisplayObject {
|
|
|
214
269
|
* @param {number} index - The index of the child to remove.
|
|
215
270
|
* @returns {DisplayObject} The removed child display object.
|
|
216
271
|
*/
|
|
217
|
-
removeChildAt(index) {
|
|
272
|
+
removeChildAt(index: number) {
|
|
218
273
|
const child = this.getChildAt(index);
|
|
219
274
|
if (child) {
|
|
220
275
|
child.parent = undefined;
|
|
@@ -230,7 +285,7 @@ export class DisplayObject {
|
|
|
230
285
|
* @returns {DisplayObject[]} The array of removed child display objects.
|
|
231
286
|
* @throws {Error} If the range is invalid.
|
|
232
287
|
*/
|
|
233
|
-
removeChildren(beginIndex, endIndex) {
|
|
288
|
+
removeChildren(beginIndex: number, endIndex: number) {
|
|
234
289
|
if (beginIndex === undefined) {
|
|
235
290
|
beginIndex = 0;
|
|
236
291
|
}
|
|
@@ -257,7 +312,7 @@ export class DisplayObject {
|
|
|
257
312
|
* @param {DisplayObject | null | undefined} parent - The parent display object to use for the world transform calculation.
|
|
258
313
|
* @returns {DisplayObject} This DisplayObject instance for chaining.
|
|
259
314
|
*/
|
|
260
|
-
updateTransform(parent = null) {
|
|
315
|
+
updateTransform(parent: DisplayObject | null | undefined = null) {
|
|
261
316
|
if (!parent && !this.parent) {
|
|
262
317
|
return this;
|
|
263
318
|
}
|
|
@@ -270,37 +325,37 @@ export class DisplayObject {
|
|
|
270
325
|
} else if (!this.parent) {
|
|
271
326
|
p = this.game.world;
|
|
272
327
|
}
|
|
273
|
-
//
|
|
328
|
+
// Create some matrix refs for easy access
|
|
274
329
|
const pt = p.worldTransform;
|
|
275
330
|
const wt = this.worldTransform;
|
|
276
|
-
//
|
|
331
|
+
// Temporary matrix variables
|
|
277
332
|
let a;
|
|
278
333
|
let b;
|
|
279
334
|
let c;
|
|
280
335
|
let d;
|
|
281
336
|
let tx;
|
|
282
337
|
let ty;
|
|
283
|
-
//
|
|
338
|
+
// So if rotation is between 0 then we can simplify the multiplication process..
|
|
284
339
|
if (this.rotation % PI_2) {
|
|
285
|
-
//
|
|
340
|
+
// Check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes
|
|
286
341
|
if (this.rotation !== this.rotationCache) {
|
|
287
342
|
this.rotationCache = this.rotation;
|
|
288
343
|
this._sr = Math.sin(this.rotation);
|
|
289
344
|
this._cr = Math.cos(this.rotation);
|
|
290
345
|
}
|
|
291
|
-
//
|
|
346
|
+
// Get the matrix values of the displayobject based on its transform properties..
|
|
292
347
|
a = this._cr * this.scale.x;
|
|
293
348
|
b = this._sr * this.scale.x;
|
|
294
349
|
c = -this._sr * this.scale.y;
|
|
295
350
|
d = this._cr * this.scale.y;
|
|
296
351
|
tx = this.position.x;
|
|
297
352
|
ty = this.position.y;
|
|
298
|
-
//
|
|
353
|
+
// Check for pivot.. not often used so geared towards that fact!
|
|
299
354
|
if (this.pivot.x || this.pivot.y) {
|
|
300
355
|
tx -= this.pivot.x * a + this.pivot.y * c;
|
|
301
356
|
ty -= this.pivot.x * b + this.pivot.y * d;
|
|
302
357
|
}
|
|
303
|
-
//
|
|
358
|
+
// Concat the parent matrix with the objects transform.
|
|
304
359
|
wt.a = a * pt.a + b * pt.c;
|
|
305
360
|
wt.b = a * pt.b + b * pt.d;
|
|
306
361
|
wt.c = c * pt.a + d * pt.c;
|
|
@@ -308,7 +363,7 @@ export class DisplayObject {
|
|
|
308
363
|
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
|
|
309
364
|
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
|
|
310
365
|
} else {
|
|
311
|
-
//
|
|
366
|
+
// Lets do the fast version as we know there is no rotation..
|
|
312
367
|
a = this.scale.x;
|
|
313
368
|
d = this.scale.y;
|
|
314
369
|
tx = this.position.x - this.pivot.x * a;
|
|
@@ -322,13 +377,13 @@ export class DisplayObject {
|
|
|
322
377
|
}
|
|
323
378
|
// Set the World values
|
|
324
379
|
this.worldAlpha = this.alpha * p.worldAlpha;
|
|
325
|
-
//
|
|
380
|
+
// This.worldPosition.setTo(wt.tx, wt.ty);
|
|
326
381
|
this.worldScale.setTo(
|
|
327
382
|
this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c),
|
|
328
383
|
this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d)
|
|
329
384
|
);
|
|
330
385
|
this.worldRotation = Math.atan2(-wt.c, wt.d);
|
|
331
|
-
//
|
|
386
|
+
// Reset the bounds each time this is called!
|
|
332
387
|
this.currentBounds = null;
|
|
333
388
|
// Custom callback?
|
|
334
389
|
if (this.transformCallback) {
|
|
@@ -345,7 +400,7 @@ export class DisplayObject {
|
|
|
345
400
|
* @param {DisplayObject} targetCoordinateSpace - The coordinate space to calculate bounds in.
|
|
346
401
|
* @returns {Rectangle} The bounds rectangle of this display object.
|
|
347
402
|
*/
|
|
348
|
-
getBounds(targetCoordinateSpace) {
|
|
403
|
+
getBounds(targetCoordinateSpace?: any) {
|
|
349
404
|
const isTargetCoordinateSpaceDisplayObject = targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
|
|
350
405
|
let isTargetCoordinateSpaceThisOrParent = true;
|
|
351
406
|
if (!isTargetCoordinateSpaceDisplayObject) {
|
|
@@ -392,13 +447,13 @@ export class DisplayObject {
|
|
|
392
447
|
const w1 = bounds.width + bounds.x;
|
|
393
448
|
const h0 = bounds.y;
|
|
394
449
|
const h1 = bounds.height + bounds.y;
|
|
395
|
-
const worldTransform = this
|
|
396
|
-
const a = worldTransform
|
|
397
|
-
const b = worldTransform
|
|
398
|
-
const c = worldTransform
|
|
399
|
-
const d = worldTransform
|
|
400
|
-
const tx = worldTransform
|
|
401
|
-
const ty = worldTransform
|
|
450
|
+
const { worldTransform } = this;
|
|
451
|
+
const { a } = worldTransform;
|
|
452
|
+
const { b } = worldTransform;
|
|
453
|
+
const { c } = worldTransform;
|
|
454
|
+
const { d } = worldTransform;
|
|
455
|
+
const { tx } = worldTransform;
|
|
456
|
+
const { ty } = worldTransform;
|
|
402
457
|
const x1 = a * w1 + c * h1 + tx;
|
|
403
458
|
const y1 = d * h1 + b * w1 + ty;
|
|
404
459
|
const x2 = a * w0 + c * h1 + tx;
|
|
@@ -455,7 +510,7 @@ export class DisplayObject {
|
|
|
455
510
|
* @param {DisplayObject} child - The child display object to check.
|
|
456
511
|
* @returns {boolean} True if the child is contained within this container, false otherwise.
|
|
457
512
|
*/
|
|
458
|
-
contains(child) {
|
|
513
|
+
contains(child: DisplayObject) {
|
|
459
514
|
if (!child) {
|
|
460
515
|
return false;
|
|
461
516
|
}
|
|
@@ -469,13 +524,13 @@ export class DisplayObject {
|
|
|
469
524
|
* Renders this display object using WebGL.
|
|
470
525
|
* @param {object} renderSession - The WebGL rendering session.
|
|
471
526
|
*/
|
|
472
|
-
renderWebGL(renderSession) {
|
|
527
|
+
renderWebGL(renderSession: any) {
|
|
473
528
|
if (!this.visible || this.alpha <= 0) {
|
|
474
529
|
return;
|
|
475
530
|
}
|
|
476
531
|
let i;
|
|
477
532
|
if (this._mask || this._filters) {
|
|
478
|
-
//
|
|
533
|
+
// Push filter first as we need to ensure the stencil buffer is correct for any masking
|
|
479
534
|
if (this._filters) {
|
|
480
535
|
renderSession.spriteBatch.flush();
|
|
481
536
|
renderSession.filterManager.pushFilter(this._filterBlock);
|
|
@@ -489,8 +544,12 @@ export class DisplayObject {
|
|
|
489
544
|
this.children[i].renderWebGL(renderSession);
|
|
490
545
|
}
|
|
491
546
|
renderSession.spriteBatch.stop();
|
|
492
|
-
if (this._mask)
|
|
493
|
-
|
|
547
|
+
if (this._mask) {
|
|
548
|
+
renderSession.maskManager.popMask(this._mask, renderSession);
|
|
549
|
+
}
|
|
550
|
+
if (this._filters) {
|
|
551
|
+
renderSession.filterManager.popFilter();
|
|
552
|
+
}
|
|
494
553
|
renderSession.spriteBatch.start();
|
|
495
554
|
} else {
|
|
496
555
|
for (i = 0; i < this.children.length; i += 1) {
|
|
@@ -503,7 +562,7 @@ export class DisplayObject {
|
|
|
503
562
|
* Renders this display object using Canvas.
|
|
504
563
|
* @param {object} renderSession - The Canvas rendering session.
|
|
505
564
|
*/
|
|
506
|
-
renderCanvas(renderSession) {
|
|
565
|
+
renderCanvas(renderSession: any) {
|
|
507
566
|
if (!this.visible || this.alpha <= 0) {
|
|
508
567
|
return;
|
|
509
568
|
}
|
|
@@ -522,21 +581,21 @@ export class DisplayObject {
|
|
|
522
581
|
* Called before the update cycle for this display object.
|
|
523
582
|
*/
|
|
524
583
|
preUpdate() {
|
|
525
|
-
//
|
|
584
|
+
// Override
|
|
526
585
|
}
|
|
527
586
|
|
|
528
587
|
/**
|
|
529
588
|
* Called during the update cycle for this display object.
|
|
530
589
|
*/
|
|
531
590
|
update() {
|
|
532
|
-
//
|
|
591
|
+
// Override
|
|
533
592
|
}
|
|
534
593
|
|
|
535
594
|
/**
|
|
536
595
|
* Called after the update cycle for this display object.
|
|
537
596
|
*/
|
|
538
597
|
postUpdate() {
|
|
539
|
-
//
|
|
598
|
+
// Override
|
|
540
599
|
}
|
|
541
600
|
|
|
542
601
|
/**
|
|
@@ -553,7 +612,7 @@ export class DisplayObject {
|
|
|
553
612
|
* @param {Point} position - The local position to convert.
|
|
554
613
|
* @returns {Point} The converted global position.
|
|
555
614
|
*/
|
|
556
|
-
toGlobal(position) {
|
|
615
|
+
toGlobal(position: Point) {
|
|
557
616
|
this.updateTransform();
|
|
558
617
|
return this.worldTransform.apply(position);
|
|
559
618
|
}
|
|
@@ -564,7 +623,7 @@ export class DisplayObject {
|
|
|
564
623
|
* @param {DisplayObject} from - The display object to convert from (defaults to this).
|
|
565
624
|
* @returns {Point} The converted local position.
|
|
566
625
|
*/
|
|
567
|
-
toLocal(position, from) {
|
|
626
|
+
toLocal(position: Point, from: DisplayObject) {
|
|
568
627
|
if (from) {
|
|
569
628
|
position = from.toGlobal(position);
|
|
570
629
|
}
|
|
@@ -576,7 +635,7 @@ export class DisplayObject {
|
|
|
576
635
|
* Renders a cached sprite for this display object.
|
|
577
636
|
* @param {object} renderSession - The rendering session.
|
|
578
637
|
*/
|
|
579
|
-
renderCachedSprite(renderSession) {
|
|
638
|
+
renderCachedSprite(renderSession: any) {
|
|
580
639
|
if (!this._cachedSprite) {
|
|
581
640
|
return;
|
|
582
641
|
}
|
|
@@ -620,8 +679,8 @@ export class DisplayObject {
|
|
|
620
679
|
* Sets the width of this display object.
|
|
621
680
|
* @param {number} value - The new width in pixels.
|
|
622
681
|
*/
|
|
623
|
-
set width(value) {
|
|
624
|
-
const width = this.getLocalBounds()
|
|
682
|
+
set width(value: number) {
|
|
683
|
+
const { width } = this.getLocalBounds();
|
|
625
684
|
if (width !== 0) {
|
|
626
685
|
this.scale.x = value / width;
|
|
627
686
|
} else {
|
|
@@ -642,8 +701,8 @@ export class DisplayObject {
|
|
|
642
701
|
* Sets the height of this display object.
|
|
643
702
|
* @param {number} value - The new height in pixels.
|
|
644
703
|
*/
|
|
645
|
-
set height(value) {
|
|
646
|
-
const height = this.getLocalBounds()
|
|
704
|
+
set height(value: number) {
|
|
705
|
+
const { height } = this.getLocalBounds();
|
|
647
706
|
if (height !== 0) {
|
|
648
707
|
this.scale.y = value / height;
|
|
649
708
|
} else {
|
|
@@ -664,7 +723,7 @@ export class DisplayObject {
|
|
|
664
723
|
* Sets the x position of this display object.
|
|
665
724
|
* @param {number} value - The new x position in pixels.
|
|
666
725
|
*/
|
|
667
|
-
set x(value) {
|
|
726
|
+
set x(value: number) {
|
|
668
727
|
this.position.x = value;
|
|
669
728
|
}
|
|
670
729
|
|
|
@@ -680,7 +739,7 @@ export class DisplayObject {
|
|
|
680
739
|
* Sets the y position of this display object.
|
|
681
740
|
* @param {number} value - The new y position in pixels.
|
|
682
741
|
*/
|
|
683
|
-
set y(value) {
|
|
742
|
+
set y(value: number) {
|
|
684
743
|
this.position.y = value;
|
|
685
744
|
}
|
|
686
745
|
|
|
@@ -719,7 +778,7 @@ export class DisplayObject {
|
|
|
719
778
|
* Sets the mask for this display object.
|
|
720
779
|
* @param {import('./graphics.js').Graphics} value - The mask object to set, or null to remove the mask.
|
|
721
780
|
*/
|
|
722
|
-
set mask(value) {
|
|
781
|
+
set mask(value: import('./graphics.js').Graphics) {
|
|
723
782
|
if (this._mask) {
|
|
724
783
|
this._mask.isMask = false;
|
|
725
784
|
}
|
|
@@ -759,7 +818,7 @@ export class DisplayObject {
|
|
|
759
818
|
* Sets the center x position of this display object.
|
|
760
819
|
* @param {number} value - The new center x position in pixels.
|
|
761
820
|
*/
|
|
762
|
-
set centerX(value) {
|
|
821
|
+
set centerX(value: number) {
|
|
763
822
|
this.x = value + this.offsetX - this.width * 0.5;
|
|
764
823
|
}
|
|
765
824
|
|
|
@@ -775,7 +834,7 @@ export class DisplayObject {
|
|
|
775
834
|
* Sets the center y position of this display object.
|
|
776
835
|
* @param {number} value - The new center y position in pixels.
|
|
777
836
|
*/
|
|
778
|
-
set centerY(value) {
|
|
837
|
+
set centerY(value: number) {
|
|
779
838
|
this.y = value + this.offsetY - this.height * 0.5;
|
|
780
839
|
}
|
|
781
840
|
|
|
@@ -791,7 +850,7 @@ export class DisplayObject {
|
|
|
791
850
|
* Sets the left x position of this display object.
|
|
792
851
|
* @param {number} value - The new left x position in pixels.
|
|
793
852
|
*/
|
|
794
|
-
set left(value) {
|
|
853
|
+
set left(value: number) {
|
|
795
854
|
this.x = value + this.offsetX;
|
|
796
855
|
}
|
|
797
856
|
|
|
@@ -807,7 +866,7 @@ export class DisplayObject {
|
|
|
807
866
|
* Sets the right x position of this display object.
|
|
808
867
|
* @param {number} value - The new right x position in pixels.
|
|
809
868
|
*/
|
|
810
|
-
set right(value) {
|
|
869
|
+
set right(value: number) {
|
|
811
870
|
this.x = value - this.width + this.offsetX;
|
|
812
871
|
}
|
|
813
872
|
|
|
@@ -823,7 +882,7 @@ export class DisplayObject {
|
|
|
823
882
|
* Sets the top y position of this display object.
|
|
824
883
|
* @param {number} value - The new top y position in pixels.
|
|
825
884
|
*/
|
|
826
|
-
set top(value) {
|
|
885
|
+
set top(value: number) {
|
|
827
886
|
this.y = value + this.offsetY;
|
|
828
887
|
}
|
|
829
888
|
|
|
@@ -839,7 +898,7 @@ export class DisplayObject {
|
|
|
839
898
|
* Sets the bottom y position of this display object.
|
|
840
899
|
* @param {number} value - The new bottom y position in pixels.
|
|
841
900
|
*/
|
|
842
|
-
set bottom(value) {
|
|
901
|
+
set bottom(value: number) {
|
|
843
902
|
this.y = value - this.height + this.offsetY;
|
|
844
903
|
}
|
|
845
904
|
}
|