@vpmedia/phaser 1.112.0 → 1.114.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.
Files changed (296) hide show
  1. package/dist/index.js +1261 -1314
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts +14 -10
  4. package/dist/phaser/core/animation.d.ts.map +1 -1
  5. package/dist/phaser/core/animation_manager.d.ts +10 -8
  6. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  7. package/dist/phaser/core/animation_parser.d.ts +5 -4
  8. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  9. package/dist/phaser/core/array_set.d.ts.map +1 -1
  10. package/dist/phaser/core/cache.d.ts +4 -3
  11. package/dist/phaser/core/cache.d.ts.map +1 -1
  12. package/dist/phaser/core/const.d.ts.map +1 -1
  13. package/dist/phaser/core/device.d.ts.map +1 -1
  14. package/dist/phaser/core/device_util.d.ts.map +1 -1
  15. package/dist/phaser/core/dom.d.ts +3 -2
  16. package/dist/phaser/core/dom.d.ts.map +1 -1
  17. package/dist/phaser/core/event_manager.d.ts.map +1 -1
  18. package/dist/phaser/core/factory.d.ts +1 -1
  19. package/dist/phaser/core/factory.d.ts.map +1 -1
  20. package/dist/phaser/core/frame.d.ts.map +1 -1
  21. package/dist/phaser/core/frame_data.d.ts.map +1 -1
  22. package/dist/phaser/core/game.d.ts.map +1 -1
  23. package/dist/phaser/core/input.d.ts +8 -6
  24. package/dist/phaser/core/input.d.ts.map +1 -1
  25. package/dist/phaser/core/input_handler.d.ts +40 -30
  26. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  27. package/dist/phaser/core/input_mouse.d.ts +3 -2
  28. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  29. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  30. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  31. package/dist/phaser/core/input_pointer.d.ts +6 -4
  32. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  33. package/dist/phaser/core/input_touch.d.ts +3 -2
  34. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  35. package/dist/phaser/core/loader.d.ts +4 -3
  36. package/dist/phaser/core/loader.d.ts.map +1 -1
  37. package/dist/phaser/core/loader_parser.d.ts +9 -8
  38. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  39. package/dist/phaser/core/raf.d.ts +3 -2
  40. package/dist/phaser/core/raf.d.ts.map +1 -1
  41. package/dist/phaser/core/registry.d.ts +7 -0
  42. package/dist/phaser/core/registry.d.ts.map +1 -0
  43. package/dist/phaser/core/scale_manager.d.ts +1 -1
  44. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  45. package/dist/phaser/core/scene.d.ts +0 -1
  46. package/dist/phaser/core/scene.d.ts.map +1 -1
  47. package/dist/phaser/core/scene_manager.d.ts +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  49. package/dist/phaser/core/signal.d.ts +0 -1
  50. package/dist/phaser/core/signal.d.ts.map +1 -1
  51. package/dist/phaser/core/signal_binding.d.ts +4 -3
  52. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  53. package/dist/phaser/core/sound.d.ts +6 -4
  54. package/dist/phaser/core/sound.d.ts.map +1 -1
  55. package/dist/phaser/core/sound_manager.d.ts +3 -2
  56. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  57. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  58. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  59. package/dist/phaser/core/stage.d.ts +3 -2
  60. package/dist/phaser/core/stage.d.ts.map +1 -1
  61. package/dist/phaser/core/time.d.ts +1 -1
  62. package/dist/phaser/core/time.d.ts.map +1 -1
  63. package/dist/phaser/core/timer.d.ts +1 -1
  64. package/dist/phaser/core/timer.d.ts.map +1 -1
  65. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  66. package/dist/phaser/core/tween.d.ts +10 -7
  67. package/dist/phaser/core/tween.d.ts.map +1 -1
  68. package/dist/phaser/core/tween_data.d.ts +3 -2
  69. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  70. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_manager.d.ts +3 -2
  72. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  73. package/dist/phaser/core/world.d.ts +3 -2
  74. package/dist/phaser/core/world.d.ts.map +1 -1
  75. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  76. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  77. package/dist/phaser/display/button.d.ts +3 -2
  78. package/dist/phaser/display/button.d.ts.map +1 -1
  79. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  81. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  82. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  83. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  84. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  85. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  86. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  87. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  88. package/dist/phaser/display/canvas/util.d.ts +2 -2
  89. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  90. package/dist/phaser/display/display_object.d.ts +14 -12
  91. package/dist/phaser/display/display_object.d.ts.map +1 -1
  92. package/dist/phaser/display/graphics.d.ts +8 -5
  93. package/dist/phaser/display/graphics.d.ts.map +1 -1
  94. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  96. package/dist/phaser/display/group.d.ts +4 -3
  97. package/dist/phaser/display/group.d.ts.map +1 -1
  98. package/dist/phaser/display/image.d.ts +13 -10
  99. package/dist/phaser/display/image.d.ts.map +1 -1
  100. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  101. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  102. package/dist/phaser/display/sprite_util.d.ts +18 -15
  103. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  104. package/dist/phaser/display/text.d.ts +12 -10
  105. package/dist/phaser/display/text.d.ts.map +1 -1
  106. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  110. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  112. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  115. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  117. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  119. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  120. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  121. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  123. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  124. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  125. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  126. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  127. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  128. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  129. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  130. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  131. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  132. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  133. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  135. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  136. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  137. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  138. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  139. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  141. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  143. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  144. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  145. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  147. package/dist/phaser/geom/circle.d.ts +4 -1
  148. package/dist/phaser/geom/circle.d.ts.map +1 -1
  149. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  150. package/dist/phaser/geom/line.d.ts +1 -1
  151. package/dist/phaser/geom/line.d.ts.map +1 -1
  152. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  153. package/dist/phaser/geom/point.d.ts.map +1 -1
  154. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  155. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  156. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  159. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  160. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  162. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  163. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  166. package/dist/phaser/util/math.d.ts.map +1 -1
  167. package/package.json +5 -5
  168. package/src/phaser/core/animation.ts +64 -60
  169. package/src/phaser/core/animation_manager.ts +50 -53
  170. package/src/phaser/core/animation_parser.ts +9 -9
  171. package/src/phaser/core/array_set.ts +16 -17
  172. package/src/phaser/core/cache.ts +92 -93
  173. package/src/phaser/core/const.ts +1 -1
  174. package/src/phaser/core/device.ts +24 -29
  175. package/src/phaser/core/device_util.ts +22 -26
  176. package/src/phaser/core/dom.ts +54 -65
  177. package/src/phaser/core/event_manager.ts +64 -94
  178. package/src/phaser/core/factory.ts +14 -14
  179. package/src/phaser/core/frame.ts +28 -28
  180. package/src/phaser/core/frame_data.test.ts +100 -0
  181. package/src/phaser/core/frame_data.ts +24 -24
  182. package/src/phaser/core/frame_util.ts +2 -2
  183. package/src/phaser/core/game.ts +47 -48
  184. package/src/phaser/core/input.ts +104 -110
  185. package/src/phaser/core/input_handler.test.ts +113 -0
  186. package/src/phaser/core/input_handler.ts +199 -218
  187. package/src/phaser/core/input_mouse.ts +71 -54
  188. package/src/phaser/core/input_mspointer.ts +52 -39
  189. package/src/phaser/core/input_pointer.ts +81 -80
  190. package/src/phaser/core/input_touch.ts +49 -36
  191. package/src/phaser/core/loader.ts +173 -152
  192. package/src/phaser/core/loader_parser.ts +39 -57
  193. package/src/phaser/core/raf.ts +8 -7
  194. package/src/phaser/core/registry.test.ts +31 -0
  195. package/src/phaser/core/registry.ts +9 -0
  196. package/src/phaser/core/scale_manager.ts +156 -152
  197. package/src/phaser/core/scene.ts +9 -13
  198. package/src/phaser/core/scene_manager.ts +47 -47
  199. package/src/phaser/core/signal.test.ts +4 -4
  200. package/src/phaser/core/signal.ts +41 -52
  201. package/src/phaser/core/signal_binding.ts +26 -25
  202. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  203. package/src/phaser/core/sound.ts +75 -83
  204. package/src/phaser/core/sound_manager.ts +52 -51
  205. package/src/phaser/core/sound_sprite.ts +17 -16
  206. package/src/phaser/core/stage.ts +25 -24
  207. package/src/phaser/core/time.ts +52 -52
  208. package/src/phaser/core/timer.test.ts +187 -0
  209. package/src/phaser/core/timer.ts +82 -69
  210. package/src/phaser/core/timer_event.ts +10 -10
  211. package/src/phaser/core/tween.ts +90 -93
  212. package/src/phaser/core/tween_data.ts +45 -51
  213. package/src/phaser/core/tween_easing.test.ts +106 -0
  214. package/src/phaser/core/tween_easing.ts +151 -123
  215. package/src/phaser/core/tween_manager.ts +19 -18
  216. package/src/phaser/core/world.ts +4 -3
  217. package/src/phaser/display/bitmap_text.ts +56 -64
  218. package/src/phaser/display/button.ts +33 -32
  219. package/src/phaser/display/canvas/buffer.ts +8 -8
  220. package/src/phaser/display/canvas/graphics.ts +36 -37
  221. package/src/phaser/display/canvas/masker.ts +2 -2
  222. package/src/phaser/display/canvas/pool.test.ts +106 -0
  223. package/src/phaser/display/canvas/pool.ts +25 -27
  224. package/src/phaser/display/canvas/renderer.ts +32 -31
  225. package/src/phaser/display/canvas/tinter.ts +25 -25
  226. package/src/phaser/display/canvas/util.ts +7 -10
  227. package/src/phaser/display/display_object.ts +114 -118
  228. package/src/phaser/display/graphics.ts +121 -119
  229. package/src/phaser/display/graphics_data.ts +12 -12
  230. package/src/phaser/display/graphics_data_util.ts +2 -3
  231. package/src/phaser/display/group.ts +50 -57
  232. package/src/phaser/display/image.ts +55 -52
  233. package/src/phaser/display/sprite_batch.ts +3 -2
  234. package/src/phaser/display/sprite_util.ts +48 -54
  235. package/src/phaser/display/text.test.ts +110 -0
  236. package/src/phaser/display/text.ts +199 -204
  237. package/src/phaser/display/webgl/abstract_filter.ts +9 -9
  238. package/src/phaser/display/webgl/base_texture.ts +21 -24
  239. package/src/phaser/display/webgl/blend_manager.ts +6 -10
  240. package/src/phaser/display/webgl/earcut.ts +73 -37
  241. package/src/phaser/display/webgl/earcut_node.ts +10 -10
  242. package/src/phaser/display/webgl/fast_sprite_batch.ts +34 -34
  243. package/src/phaser/display/webgl/filter_manager.ts +13 -12
  244. package/src/phaser/display/webgl/filter_texture.ts +14 -13
  245. package/src/phaser/display/webgl/graphics.ts +51 -57
  246. package/src/phaser/display/webgl/graphics_data.ts +15 -14
  247. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  248. package/src/phaser/display/webgl/render_texture.ts +26 -25
  249. package/src/phaser/display/webgl/renderer.ts +57 -62
  250. package/src/phaser/display/webgl/shader/complex.ts +28 -12
  251. package/src/phaser/display/webgl/shader/fast.ts +30 -12
  252. package/src/phaser/display/webgl/shader/normal.ts +70 -57
  253. package/src/phaser/display/webgl/shader/primitive.ts +26 -11
  254. package/src/phaser/display/webgl/shader/shader.test.ts +148 -0
  255. package/src/phaser/display/webgl/shader/strip.ts +27 -12
  256. package/src/phaser/display/webgl/shader_manager.test.ts +124 -0
  257. package/src/phaser/display/webgl/shader_manager.ts +26 -34
  258. package/src/phaser/display/webgl/sprite_batch.ts +67 -61
  259. package/src/phaser/display/webgl/stencil_manager.ts +23 -34
  260. package/src/phaser/display/webgl/texture.ts +43 -50
  261. package/src/phaser/display/webgl/texture_util.ts +2 -3
  262. package/src/phaser/display/webgl/util.ts +26 -25
  263. package/src/phaser/geom/circle.test.ts +2 -3
  264. package/src/phaser/geom/circle.ts +36 -36
  265. package/src/phaser/geom/ellipse.test.ts +73 -71
  266. package/src/phaser/geom/ellipse.ts +14 -14
  267. package/src/phaser/geom/line.test.ts +5 -5
  268. package/src/phaser/geom/line.ts +35 -35
  269. package/src/phaser/geom/matrix.test.ts +1 -1
  270. package/src/phaser/geom/matrix.ts +27 -27
  271. package/src/phaser/geom/point.test.ts +1 -2
  272. package/src/phaser/geom/point.ts +35 -35
  273. package/src/phaser/geom/polygon.test.ts +82 -0
  274. package/src/phaser/geom/polygon.ts +16 -16
  275. package/src/phaser/geom/rectangle.test.ts +14 -14
  276. package/src/phaser/geom/rectangle.ts +83 -75
  277. package/src/phaser/geom/rounded_rectangle.test.ts +1 -7
  278. package/src/phaser/geom/rounded_rectangle.ts +9 -9
  279. package/src/phaser/geom/util/circle.test.ts +25 -23
  280. package/src/phaser/geom/util/circle.ts +9 -18
  281. package/src/phaser/geom/util/ellipse.test.ts +7 -5
  282. package/src/phaser/geom/util/ellipse.ts +3 -2
  283. package/src/phaser/geom/util/line.test.ts +10 -8
  284. package/src/phaser/geom/util/line.ts +6 -16
  285. package/src/phaser/geom/util/matrix.test.ts +20 -18
  286. package/src/phaser/geom/util/matrix.ts +8 -15
  287. package/src/phaser/geom/util/point.test.ts +8 -6
  288. package/src/phaser/geom/util/point.ts +24 -28
  289. package/src/phaser/geom/util/polygon.test.ts +12 -10
  290. package/src/phaser/geom/util/polygon.ts +2 -2
  291. package/src/phaser/geom/util/rectangle.test.ts +10 -8
  292. package/src/phaser/geom/util/rectangle.ts +18 -37
  293. package/src/phaser/geom/util/rounded_rectangle.test.ts +11 -9
  294. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
  295. package/src/phaser/util/math.test.ts +11 -11
  296. package/src/phaser/util/math.ts +29 -46
@@ -4,66 +4,68 @@ import { Rectangle } from '../geom/rectangle.js';
4
4
  import { getIdentityMatrix } from '../geom/util/matrix.js';
5
5
  import { PI_2 } from '../util/math.js';
6
6
  import { renderCanvas, renderWebGL } from './sprite_util.js';
7
+ import type { Graphics } from './graphics.js';
8
+ import type { Game } from '../core/game.js';
7
9
 
8
10
  export class DisplayObject {
9
11
  /** @type {boolean} */
10
- exists = true;
12
+ public exists = true;
11
13
  /** @type {boolean} */
12
- renderable = false;
14
+ public renderable = false;
13
15
  /** @type {boolean} */
14
- visible = true;
15
- position!: Point;
16
- scale!: Point;
17
- pivot!: Point;
18
- anchor!: Point;
16
+ public visible = true;
17
+ public position!: Point;
18
+ public scale!: Point;
19
+ public pivot!: Point;
20
+ public anchor!: Point;
19
21
  /** @type {number} */
20
- rotation = 0;
22
+ public rotation = 0;
21
23
  /** @type {number} */
22
- alpha = 1;
23
- hitArea: Rectangle | null = null;
24
- parent: DisplayObject | null = null;
24
+ public alpha = 1;
25
+ public hitArea: Rectangle | null = null;
26
+ public parent: DisplayObject | null = null;
25
27
  /** @type {number} */
26
- worldAlpha = 1;
27
- worldTransform!: Matrix;
28
- worldScale!: Point;
29
- filterArea: Rectangle | null = null;
28
+ public worldAlpha = 1;
29
+ public worldTransform!: Matrix;
30
+ public worldScale!: Point;
31
+ public filterArea: Rectangle | null = null;
30
32
  /** @type {number} */
31
- _sr = 0;
33
+ public _sr = 0;
32
34
  /** @type {number} */
33
- _cr = 1;
34
- cachedBounds!: Rectangle;
35
- currentBounds: Rectangle | null = null;
36
- _mask: import('./graphics.js').Graphics | null = null;
37
- _filters: object[] | null = null;
38
- _filterBlock: object | null = null;
39
- children!: DisplayObject[];
35
+ public _cr = 1;
36
+ public cachedBounds!: Rectangle;
37
+ public currentBounds: Rectangle | null = null;
38
+ public _mask: Graphics | null = null;
39
+ public _filters: object[] | null = null;
40
+ public _filterBlock: object | null = null;
41
+ public children!: DisplayObject[];
40
42
  /** @type {boolean} */
41
- ignoreChildInput = false;
42
- name: string | null = null;
43
- data: any = null;
44
- game!: import('../core/game.js').Game;
45
- type!: number;
46
- _cachedSprite!: any;
47
- rotationCache!: number;
48
- worldRotation!: number;
49
- transformCallback!: any;
50
- transformCallbackContext!: any;
51
- _width!: number;
52
- _height!: number;
53
- z!: number;
54
- events!: any;
55
- renderOrderID!: number;
43
+ public ignoreChildInput = false;
44
+ public name: string | null = null;
45
+ public data: any = null;
46
+ public game!: Game;
47
+ public type!: number;
48
+ public _cachedSprite!: any;
49
+ public rotationCache!: number;
50
+ public worldRotation!: number;
51
+ public transformCallback!: any;
52
+ public transformCallbackContext!: any;
53
+ public _width!: number;
54
+ public _height!: number;
55
+ public z!: number;
56
+ public events!: any;
57
+ public renderOrderID!: number;
56
58
  /**
57
59
  * Creates a new DisplayObject instance.
58
- * @param {import('../core/game.js').Game} game - The game instance this display object belongs to.
60
+ * @param {Game} game - The game instance this display object belongs to.
59
61
  */
60
- constructor(game: import('../core/game.js').Game) {
62
+ public constructor(game: Game) {
61
63
  /** @type {boolean} */
62
- this.exists = true;
64
+
63
65
  /** @type {boolean} */
64
- this.renderable = false;
66
+
65
67
  /** @type {boolean} */
66
- this.visible = true;
68
+
67
69
  /** @type {Point} */
68
70
  this.position = new Point(0, 0);
69
71
  /** @type {Point} */
@@ -98,7 +100,7 @@ export class DisplayObject {
98
100
  this.cachedBounds = new Rectangle(0, 0, 0, 0);
99
101
  /** @type {Rectangle} */
100
102
  this.currentBounds = null;
101
- /** @type {import('./graphics.js').Graphics} */
103
+ /** @type {Graphics} */
102
104
  this._mask = null;
103
105
  /** @type {object[]} */
104
106
  this._filters = null;
@@ -111,19 +113,19 @@ export class DisplayObject {
111
113
  this.name = this.name ?? null;
112
114
  /** @type {object | null } */
113
115
  this.data = this.data ?? null;
114
- /** @type {import('../core/game.js').Game } */
116
+ /** @type {Game } */
115
117
  this.game = game;
116
118
  }
117
119
 
118
120
  /**
119
121
  * Destroys this display object and cleans up resources.
120
122
  */
121
- destroy() {
123
+ public destroy() {
122
124
  if (this.children) {
123
125
  let i = this.children.length;
124
126
  while (i) {
125
127
  i -= 1;
126
- this.children[i].destroy();
128
+ this.children[i]!.destroy();
127
129
  }
128
130
  }
129
131
  this.children = null!;
@@ -154,7 +156,7 @@ export class DisplayObject {
154
156
  * @param {DisplayObject} child - The child display object to add.
155
157
  * @returns {DisplayObject} The added child display object.
156
158
  */
157
- addChild(child: DisplayObject) {
159
+ public addChild(child: DisplayObject) {
158
160
  return this.addChildAt(child, this.children.length);
159
161
  }
160
162
 
@@ -165,7 +167,7 @@ export class DisplayObject {
165
167
  * @returns {DisplayObject} The added child display object.
166
168
  * @throws {Error} If the index is out of bounds.
167
169
  */
168
- addChildAt(child: DisplayObject, index: number) {
170
+ public addChildAt(child: DisplayObject, index: number) {
169
171
  if (index >= 0 && index <= this.children.length) {
170
172
  if (child.parent) {
171
173
  child.parent.removeChild(child);
@@ -183,7 +185,7 @@ export class DisplayObject {
183
185
  * @param {DisplayObject} child2 - The second child display object.
184
186
  * @throws {Error} If either child is not a child of this container.
185
187
  */
186
- swapChildren(child: DisplayObject, child2: DisplayObject) {
188
+ public swapChildren(child: DisplayObject, child2: DisplayObject) {
187
189
  if (child === child2) {
188
190
  return;
189
191
  }
@@ -202,7 +204,7 @@ export class DisplayObject {
202
204
  * @returns {number} The index of the child in the children list.
203
205
  * @throws {Error} If the child is not a child of this container.
204
206
  */
205
- getChildIndex(child: DisplayObject) {
207
+ public getChildIndex(child: DisplayObject) {
206
208
  const index = this.children.indexOf(child);
207
209
  if (index === -1) {
208
210
  throw new Error('The supplied DisplayObject must be a child of the caller');
@@ -216,7 +218,7 @@ export class DisplayObject {
216
218
  * @param {number} index - The new index for the child.
217
219
  * @throws {Error} If the index is out of bounds.
218
220
  */
219
- setChildIndex(child: DisplayObject, index: number) {
221
+ public setChildIndex(child: DisplayObject, index: number) {
220
222
  if (index < 0 || index >= this.children.length) {
221
223
  throw new Error('The supplied index is out of bounds');
222
224
  }
@@ -231,7 +233,7 @@ export class DisplayObject {
231
233
  * @returns {DisplayObject} The child display object at the specified index.
232
234
  * @throws {Error} If the index is out of bounds.
233
235
  */
234
- getChildAt(index: number) {
236
+ public getChildAt(index: number) {
235
237
  if (index < 0 || index >= this.children.length) {
236
238
  throw new Error(
237
239
  `getChildAt: Supplied index ${
@@ -247,7 +249,7 @@ export class DisplayObject {
247
249
  * @param {DisplayObject} child - The child display object to remove.
248
250
  * @returns {DisplayObject} The removed child display object.
249
251
  */
250
- removeChild(child: DisplayObject) {
252
+ public removeChild(child: DisplayObject) {
251
253
  const index = this.children.indexOf(child);
252
254
  if (index === -1) {
253
255
  return null;
@@ -260,7 +262,7 @@ export class DisplayObject {
260
262
  * @param {number} index - The index of the child to remove.
261
263
  * @returns {DisplayObject} The removed child display object.
262
264
  */
263
- removeChildAt(index: number) {
265
+ public removeChildAt(index: number) {
264
266
  const child = this.getChildAt(index);
265
267
  if (child) {
266
268
  child.parent = null;
@@ -276,18 +278,13 @@ export class DisplayObject {
276
278
  * @returns {DisplayObject[]} The array of removed child display objects.
277
279
  * @throws {Error} If the range is invalid.
278
280
  */
279
- removeChildren(beginIndex: number, endIndex: number) {
280
- if (beginIndex === undefined) {
281
- beginIndex = 0;
282
- }
283
- if (endIndex === undefined) {
284
- endIndex = this.children.length;
285
- }
281
+ public removeChildren(beginIndex: number, endIndex: number) {
282
+ beginIndex ??= 0;
283
+ endIndex ??= this.children.length;
286
284
  const range = endIndex - beginIndex;
287
285
  if (range > 0 && range <= endIndex) {
288
286
  const removed = this.children.splice(beginIndex, range);
289
- for (let i = 0; i < removed.length; i += 1) {
290
- const child = removed[i];
287
+ for (const child of removed) {
291
288
  child.parent = null;
292
289
  }
293
290
  return removed;
@@ -303,7 +300,7 @@ export class DisplayObject {
303
300
  * @param {DisplayObject | null | undefined} parent - The parent display object to use for the world transform calculation.
304
301
  * @returns {DisplayObject} This DisplayObject instance for chaining.
305
302
  */
306
- updateTransform(parent: DisplayObject | null | undefined = null) {
303
+ public updateTransform(parent: DisplayObject | null | undefined = null) {
307
304
  if (!parent && !this.parent) {
308
305
  return this;
309
306
  }
@@ -375,8 +372,8 @@ export class DisplayObject {
375
372
  if (this.transformCallback) {
376
373
  this.transformCallback.call(this.transformCallbackContext, wt, pt);
377
374
  }
378
- for (let i = 0; i < this.children.length; i += 1) {
379
- this.children[i].updateTransform();
375
+ for (const child of this.children) {
376
+ child.updateTransform();
380
377
  }
381
378
  return this;
382
379
  }
@@ -386,7 +383,7 @@ export class DisplayObject {
386
383
  * @param {DisplayObject} targetCoordinateSpace - The coordinate space to calculate bounds in.
387
384
  * @returns {Rectangle} The bounds rectangle of this display object.
388
385
  */
389
- getBounds(targetCoordinateSpace?: any) {
386
+ public getBounds(targetCoordinateSpace?: any) {
390
387
  const isTargetCoordinateSpaceDisplayObject = targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
391
388
  let isTargetCoordinateSpaceThisOrParent = true;
392
389
  if (!isTargetCoordinateSpaceDisplayObject) {
@@ -414,10 +411,10 @@ export class DisplayObject {
414
411
  let childMaxY;
415
412
  let childVisible = false;
416
413
  for (i = 0; i < this.children.length; i += 1) {
417
- const child = this.children[i];
414
+ const child = this.children[i]!;
418
415
  if (child.visible) {
419
416
  childVisible = true;
420
- childBounds = this.children[i].getBounds();
417
+ childBounds = child.getBounds();
421
418
  minX = minX < childBounds.x ? minX : childBounds.x;
422
419
  minY = minY < childBounds.y ? minY : childBounds.y;
423
420
  childMaxX = childBounds.width + childBounds.x;
@@ -487,7 +484,7 @@ export class DisplayObject {
487
484
  * Gets the bounds of this display object in local coordinates.
488
485
  * @returns {Rectangle} The bounds rectangle of this display object in local space.
489
486
  */
490
- getLocalBounds() {
487
+ public getLocalBounds() {
491
488
  return this.getBounds(this);
492
489
  }
493
490
 
@@ -496,7 +493,7 @@ export class DisplayObject {
496
493
  * @param {DisplayObject} child - The child display object to check.
497
494
  * @returns {boolean} True if the child is contained within this container, false otherwise.
498
495
  */
499
- contains(child: DisplayObject | null): boolean {
496
+ public contains(child: DisplayObject | null): boolean {
500
497
  if (!child) {
501
498
  return false;
502
499
  }
@@ -509,13 +506,12 @@ export class DisplayObject {
509
506
  /**
510
507
  * Renders this display object using WebGL.
511
508
  * @param {object} renderSession - The WebGL rendering session.
512
- * @param {import('../geom/matrix.js').Matrix | null} _matrix - The transform matrix to render with.
509
+ * @param {Matrix | null} _matrix - The transform matrix to render with.
513
510
  */
514
- renderWebGL(renderSession: any, _matrix: Matrix | null = null) {
511
+ public renderWebGL(renderSession: any, _matrix: Matrix | null = null) {
515
512
  if (!this.visible || this.alpha <= 0) {
516
513
  return;
517
514
  }
518
- let i;
519
515
  if (this._mask || this._filters) {
520
516
  // Push filter first as we need to ensure the stencil buffer is correct for any masking
521
517
  if (this._filters) {
@@ -527,8 +523,8 @@ export class DisplayObject {
527
523
  renderSession.maskManager.pushMask(this.mask, renderSession);
528
524
  renderSession.spriteBatch.start();
529
525
  }
530
- for (i = 0; i < this.children.length; i += 1) {
531
- this.children[i].renderWebGL(renderSession);
526
+ for (const child of this.children) {
527
+ child.renderWebGL(renderSession);
532
528
  }
533
529
  renderSession.spriteBatch.stop();
534
530
  if (this._mask) {
@@ -539,8 +535,8 @@ export class DisplayObject {
539
535
  }
540
536
  renderSession.spriteBatch.start();
541
537
  } else {
542
- for (i = 0; i < this.children.length; i += 1) {
543
- this.children[i].renderWebGL(renderSession);
538
+ for (const child of this.children) {
539
+ child.renderWebGL(renderSession);
544
540
  }
545
541
  }
546
542
  }
@@ -549,15 +545,15 @@ export class DisplayObject {
549
545
  * Renders this display object using Canvas.
550
546
  * @param {object} renderSession - The Canvas rendering session.
551
547
  */
552
- renderCanvas(renderSession: any) {
548
+ public renderCanvas(renderSession: any) {
553
549
  if (!this.visible || this.alpha <= 0) {
554
550
  return;
555
551
  }
556
552
  if (this._mask) {
557
553
  renderSession.maskManager.pushMask(this._mask, renderSession);
558
554
  }
559
- for (let i = 0; i < this.children.length; i += 1) {
560
- this.children[i].renderCanvas(renderSession);
555
+ for (const child of this.children) {
556
+ child.renderCanvas(renderSession);
561
557
  }
562
558
  if (this._mask) {
563
559
  renderSession.maskManager.popMask(renderSession);
@@ -567,21 +563,21 @@ export class DisplayObject {
567
563
  /**
568
564
  * Called before the update cycle for this display object.
569
565
  */
570
- preUpdate() {
566
+ public preUpdate() {
571
567
  // Override
572
568
  }
573
569
 
574
570
  /**
575
571
  * Called during the update cycle for this display object.
576
572
  */
577
- update() {
573
+ public update() {
578
574
  // Override
579
575
  }
580
576
 
581
577
  /**
582
578
  * Called after the update cycle for this display object.
583
579
  */
584
- postUpdate() {
580
+ public postUpdate() {
585
581
  // Override
586
582
  }
587
583
 
@@ -589,7 +585,7 @@ export class DisplayObject {
589
585
  * Generates a texture for this display object.
590
586
  * @throws {Error} This method is not implemented yet.
591
587
  */
592
- generateTexture() {
588
+ public generateTexture() {
593
589
  // TODO
594
590
  throw new Error('display_object.generateTexture() is not implemented');
595
591
  }
@@ -599,7 +595,7 @@ export class DisplayObject {
599
595
  * @param {Point} position - The local position to convert.
600
596
  * @returns {Point} The converted global position.
601
597
  */
602
- toGlobal(position: Point) {
598
+ public toGlobal(position: Point) {
603
599
  this.updateTransform();
604
600
  return this.worldTransform.apply(position);
605
601
  }
@@ -610,7 +606,7 @@ export class DisplayObject {
610
606
  * @param {DisplayObject} from - The display object to convert from (defaults to this).
611
607
  * @returns {Point} The converted local position.
612
608
  */
613
- toLocal(position: Point, from: DisplayObject) {
609
+ public toLocal(position: Point, from: DisplayObject) {
614
610
  if (from) {
615
611
  position = from.toGlobal(position);
616
612
  }
@@ -622,7 +618,7 @@ export class DisplayObject {
622
618
  * Renders a cached sprite for this display object.
623
619
  * @param {object} renderSession - The rendering session.
624
620
  */
625
- renderCachedSprite(renderSession: any) {
621
+ public renderCachedSprite(renderSession: any) {
626
622
  if (!this._cachedSprite) {
627
623
  return;
628
624
  }
@@ -637,14 +633,14 @@ export class DisplayObject {
637
633
  /**
638
634
  * Generates a cached sprite for this display object.
639
635
  */
640
- generateCachedSprite() {
636
+ public generateCachedSprite() {
641
637
  // TODO
642
638
  }
643
639
 
644
640
  /**
645
641
  * Destroys the cached sprite for this display object.
646
642
  */
647
- destroyCachedSprite() {
643
+ public destroyCachedSprite() {
648
644
  if (!this._cachedSprite) {
649
645
  return;
650
646
  }
@@ -658,7 +654,7 @@ export class DisplayObject {
658
654
  * Gets the width of this display object.
659
655
  * @returns {number} The width in pixels.
660
656
  */
661
- get width() {
657
+ public get width() {
662
658
  return this.getLocalBounds().width * this.scale.x;
663
659
  }
664
660
 
@@ -666,7 +662,7 @@ export class DisplayObject {
666
662
  * Sets the width of this display object.
667
663
  * @param {number} value - The new width in pixels.
668
664
  */
669
- set width(value: number) {
665
+ public set width(value: number) {
670
666
  const { width } = this.getLocalBounds();
671
667
  if (width !== 0) {
672
668
  this.scale.x = value / width;
@@ -680,7 +676,7 @@ export class DisplayObject {
680
676
  * Gets the height of this display object.
681
677
  * @returns {number} The height in pixels.
682
678
  */
683
- get height() {
679
+ public get height() {
684
680
  return this.getLocalBounds().height * this.scale.y;
685
681
  }
686
682
 
@@ -688,7 +684,7 @@ export class DisplayObject {
688
684
  * Sets the height of this display object.
689
685
  * @param {number} value - The new height in pixels.
690
686
  */
691
- set height(value: number) {
687
+ public set height(value: number) {
692
688
  const { height } = this.getLocalBounds();
693
689
  if (height !== 0) {
694
690
  this.scale.y = value / height;
@@ -702,7 +698,7 @@ export class DisplayObject {
702
698
  * Gets the x position of this display object.
703
699
  * @returns {number} The x position in pixels.
704
700
  */
705
- get x() {
701
+ public get x() {
706
702
  return this.position.x;
707
703
  }
708
704
 
@@ -710,7 +706,7 @@ export class DisplayObject {
710
706
  * Sets the x position of this display object.
711
707
  * @param {number} value - The new x position in pixels.
712
708
  */
713
- set x(value: number) {
709
+ public set x(value: number) {
714
710
  this.position.x = value;
715
711
  }
716
712
 
@@ -718,7 +714,7 @@ export class DisplayObject {
718
714
  * Gets the y position of this display object.
719
715
  * @returns {number} The y position in pixels.
720
716
  */
721
- get y() {
717
+ public get y() {
722
718
  return this.position.y;
723
719
  }
724
720
 
@@ -726,7 +722,7 @@ export class DisplayObject {
726
722
  * Sets the y position of this display object.
727
723
  * @param {number} value - The new y position in pixels.
728
724
  */
729
- set y(value: number) {
725
+ public set y(value: number) {
730
726
  this.position.y = value;
731
727
  }
732
728
 
@@ -734,7 +730,7 @@ export class DisplayObject {
734
730
  * Gets whether this display object is visible in the world.
735
731
  * @returns {boolean} True if the object is visible, false otherwise.
736
732
  */
737
- get worldVisible() {
733
+ public get worldVisible() {
738
734
  if (!this.visible) {
739
735
  return false;
740
736
  }
@@ -755,17 +751,17 @@ export class DisplayObject {
755
751
 
756
752
  /**
757
753
  * Gets the mask for this display object.
758
- * @returns {import('./graphics.js').Graphics} The mask object or null if none is set.
754
+ * @returns {Graphics} The mask object or null if none is set.
759
755
  */
760
- get mask() {
756
+ public get mask() {
761
757
  return this._mask;
762
758
  }
763
759
 
764
760
  /**
765
761
  * Sets the mask for this display object.
766
- * @param {import('./graphics.js').Graphics} value - The mask object to set, or null to remove the mask.
762
+ * @param {Graphics} value - The mask object to set, or null to remove the mask.
767
763
  */
768
- set mask(value: import('./graphics.js').Graphics | null) {
764
+ public set mask(value: Graphics | null) {
769
765
  if (this._mask) {
770
766
  this._mask.isMask = false;
771
767
  }
@@ -781,7 +777,7 @@ export class DisplayObject {
781
777
  * Gets the x offset for this display object (based on anchor point).
782
778
  * @returns {number} The x offset in pixels.
783
779
  */
784
- get offsetX() {
780
+ public get offsetX() {
785
781
  return this.anchor.x * this.width;
786
782
  }
787
783
 
@@ -789,7 +785,7 @@ export class DisplayObject {
789
785
  * Gets the y offset for this display object (based on anchor point).
790
786
  * @returns {number} The y offset in pixels.
791
787
  */
792
- get offsetY() {
788
+ public get offsetY() {
793
789
  return this.anchor.y * this.height;
794
790
  }
795
791
 
@@ -797,7 +793,7 @@ export class DisplayObject {
797
793
  * Gets the center x position of this display object.
798
794
  * @returns {number} The center x position in pixels.
799
795
  */
800
- get centerX() {
796
+ public get centerX() {
801
797
  return this.x - this.offsetX + this.width * 0.5;
802
798
  }
803
799
 
@@ -805,7 +801,7 @@ export class DisplayObject {
805
801
  * Sets the center x position of this display object.
806
802
  * @param {number} value - The new center x position in pixels.
807
803
  */
808
- set centerX(value: number) {
804
+ public set centerX(value: number) {
809
805
  this.x = value + this.offsetX - this.width * 0.5;
810
806
  }
811
807
 
@@ -813,7 +809,7 @@ export class DisplayObject {
813
809
  * Gets the center y position of this display object.
814
810
  * @returns {number} The center y position in pixels.
815
811
  */
816
- get centerY() {
812
+ public get centerY() {
817
813
  return this.y - this.offsetY + this.height * 0.5;
818
814
  }
819
815
 
@@ -821,7 +817,7 @@ export class DisplayObject {
821
817
  * Sets the center y position of this display object.
822
818
  * @param {number} value - The new center y position in pixels.
823
819
  */
824
- set centerY(value: number) {
820
+ public set centerY(value: number) {
825
821
  this.y = value + this.offsetY - this.height * 0.5;
826
822
  }
827
823
 
@@ -829,7 +825,7 @@ export class DisplayObject {
829
825
  * Gets the left x position of this display object.
830
826
  * @returns {number} The left x position in pixels.
831
827
  */
832
- get left() {
828
+ public get left() {
833
829
  return this.x - this.offsetX;
834
830
  }
835
831
 
@@ -837,7 +833,7 @@ export class DisplayObject {
837
833
  * Sets the left x position of this display object.
838
834
  * @param {number} value - The new left x position in pixels.
839
835
  */
840
- set left(value: number) {
836
+ public set left(value: number) {
841
837
  this.x = value + this.offsetX;
842
838
  }
843
839
 
@@ -845,7 +841,7 @@ export class DisplayObject {
845
841
  * Gets the right x position of this display object.
846
842
  * @returns {number} The right x position in pixels.
847
843
  */
848
- get right() {
844
+ public get right() {
849
845
  return this.x + this.width - this.offsetX;
850
846
  }
851
847
 
@@ -853,7 +849,7 @@ export class DisplayObject {
853
849
  * Sets the right x position of this display object.
854
850
  * @param {number} value - The new right x position in pixels.
855
851
  */
856
- set right(value: number) {
852
+ public set right(value: number) {
857
853
  this.x = value - this.width + this.offsetX;
858
854
  }
859
855
 
@@ -861,7 +857,7 @@ export class DisplayObject {
861
857
  * Gets the top y position of this display object.
862
858
  * @returns {number} The top y position in pixels.
863
859
  */
864
- get top() {
860
+ public get top() {
865
861
  return this.y - this.offsetY;
866
862
  }
867
863
 
@@ -869,7 +865,7 @@ export class DisplayObject {
869
865
  * Sets the top y position of this display object.
870
866
  * @param {number} value - The new top y position in pixels.
871
867
  */
872
- set top(value: number) {
868
+ public set top(value: number) {
873
869
  this.y = value + this.offsetY;
874
870
  }
875
871
 
@@ -877,7 +873,7 @@ export class DisplayObject {
877
873
  * Gets the bottom y position of this display object.
878
874
  * @returns {number} The bottom y position in pixels.
879
875
  */
880
- get bottom() {
876
+ public get bottom() {
881
877
  return this.y + this.height - this.offsetY;
882
878
  }
883
879
 
@@ -885,7 +881,7 @@ export class DisplayObject {
885
881
  * Sets the bottom y position of this display object.
886
882
  * @param {number} value - The new bottom y position in pixels.
887
883
  */
888
- set bottom(value: number) {
884
+ public set bottom(value: number) {
889
885
  this.y = value - this.height + this.offsetY;
890
886
  }
891
887
  }