@vpmedia/phaser 1.111.0 → 1.113.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 +1300 -1334
  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 +1 -1
  23. package/dist/phaser/core/game.d.ts.map +1 -1
  24. package/dist/phaser/core/input.d.ts +8 -6
  25. package/dist/phaser/core/input.d.ts.map +1 -1
  26. package/dist/phaser/core/input_handler.d.ts +40 -30
  27. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  28. package/dist/phaser/core/input_mouse.d.ts +3 -2
  29. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  30. package/dist/phaser/core/input_mspointer.d.ts +3 -2
  31. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  32. package/dist/phaser/core/input_pointer.d.ts +6 -4
  33. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  34. package/dist/phaser/core/input_touch.d.ts +3 -2
  35. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  36. package/dist/phaser/core/loader.d.ts +4 -3
  37. package/dist/phaser/core/loader.d.ts.map +1 -1
  38. package/dist/phaser/core/loader_parser.d.ts +9 -8
  39. package/dist/phaser/core/loader_parser.d.ts.map +1 -1
  40. package/dist/phaser/core/raf.d.ts +3 -2
  41. package/dist/phaser/core/raf.d.ts.map +1 -1
  42. package/dist/phaser/core/registry.d.ts +7 -0
  43. package/dist/phaser/core/registry.d.ts.map +1 -0
  44. package/dist/phaser/core/scale_manager.d.ts +1 -1
  45. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  46. package/dist/phaser/core/scene.d.ts +0 -1
  47. package/dist/phaser/core/scene.d.ts.map +1 -1
  48. package/dist/phaser/core/scene_manager.d.ts +1 -1
  49. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  50. package/dist/phaser/core/signal.d.ts +0 -1
  51. package/dist/phaser/core/signal.d.ts.map +1 -1
  52. package/dist/phaser/core/signal_binding.d.ts +4 -3
  53. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  54. package/dist/phaser/core/sound.d.ts +6 -4
  55. package/dist/phaser/core/sound.d.ts.map +1 -1
  56. package/dist/phaser/core/sound_manager.d.ts +3 -2
  57. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  58. package/dist/phaser/core/sound_sprite.d.ts +5 -4
  59. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  60. package/dist/phaser/core/stage.d.ts +3 -2
  61. package/dist/phaser/core/stage.d.ts.map +1 -1
  62. package/dist/phaser/core/time.d.ts +1 -1
  63. package/dist/phaser/core/time.d.ts.map +1 -1
  64. package/dist/phaser/core/timer.d.ts +1 -1
  65. package/dist/phaser/core/timer.d.ts.map +1 -1
  66. package/dist/phaser/core/timer_event.d.ts.map +1 -1
  67. package/dist/phaser/core/tween.d.ts +10 -7
  68. package/dist/phaser/core/tween.d.ts.map +1 -1
  69. package/dist/phaser/core/tween_data.d.ts +3 -2
  70. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  71. package/dist/phaser/core/tween_easing.d.ts.map +1 -1
  72. package/dist/phaser/core/tween_manager.d.ts +3 -2
  73. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  74. package/dist/phaser/core/world.d.ts +3 -2
  75. package/dist/phaser/core/world.d.ts.map +1 -1
  76. package/dist/phaser/display/bitmap_text.d.ts +3 -2
  77. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  78. package/dist/phaser/display/button.d.ts +3 -2
  79. package/dist/phaser/display/button.d.ts.map +1 -1
  80. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  81. package/dist/phaser/display/canvas/graphics.d.ts +7 -6
  82. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  83. package/dist/phaser/display/canvas/pool.d.ts +2 -2
  84. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  85. package/dist/phaser/display/canvas/renderer.d.ts +10 -8
  86. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  87. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  88. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  89. package/dist/phaser/display/canvas/util.d.ts +2 -2
  90. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  91. package/dist/phaser/display/display_object.d.ts +14 -12
  92. package/dist/phaser/display/display_object.d.ts.map +1 -1
  93. package/dist/phaser/display/graphics.d.ts +8 -5
  94. package/dist/phaser/display/graphics.d.ts.map +1 -1
  95. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  96. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  97. package/dist/phaser/display/group.d.ts +4 -3
  98. package/dist/phaser/display/group.d.ts.map +1 -1
  99. package/dist/phaser/display/image.d.ts +13 -10
  100. package/dist/phaser/display/image.d.ts.map +1 -1
  101. package/dist/phaser/display/sprite_batch.d.ts +3 -2
  102. package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
  103. package/dist/phaser/display/sprite_util.d.ts +18 -15
  104. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  105. package/dist/phaser/display/text.d.ts +11 -9
  106. package/dist/phaser/display/text.d.ts.map +1 -1
  107. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  108. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  109. package/dist/phaser/display/webgl/blend_manager.d.ts +0 -1
  110. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  111. package/dist/phaser/display/webgl/earcut.d.ts +1 -1
  112. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  113. package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  114. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +4 -3
  115. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  116. package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
  117. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  118. package/dist/phaser/display/webgl/filter_texture.d.ts +2 -1
  119. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  120. package/dist/phaser/display/webgl/graphics.d.ts +7 -6
  121. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  122. package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
  123. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  124. package/dist/phaser/display/webgl/render_texture.d.ts +4 -2
  125. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  126. package/dist/phaser/display/webgl/renderer.d.ts +16 -11
  127. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  128. package/dist/phaser/display/webgl/shader/complex.d.ts +16 -6
  129. package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  130. package/dist/phaser/display/webgl/shader/fast.d.ts +19 -7
  131. package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  132. package/dist/phaser/display/webgl/shader/normal.d.ts +33 -12
  133. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  134. package/dist/phaser/display/webgl/shader/primitive.d.ts +15 -6
  135. package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  136. package/dist/phaser/display/webgl/shader/strip.d.ts +15 -6
  137. package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  138. package/dist/phaser/display/webgl/shader_manager.d.ts +16 -11
  139. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  140. package/dist/phaser/display/webgl/sprite_batch.d.ts +29 -20
  141. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  142. package/dist/phaser/display/webgl/stencil_manager.d.ts +12 -10
  143. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  144. package/dist/phaser/display/webgl/texture.d.ts +3 -2
  145. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  146. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  147. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  148. package/dist/phaser/geom/circle.d.ts +4 -1
  149. package/dist/phaser/geom/circle.d.ts.map +1 -1
  150. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  151. package/dist/phaser/geom/line.d.ts +1 -1
  152. package/dist/phaser/geom/line.d.ts.map +1 -1
  153. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  154. package/dist/phaser/geom/point.d.ts.map +1 -1
  155. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  156. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  157. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  158. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  159. package/dist/phaser/geom/util/ellipse.d.ts +3 -2
  160. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  161. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  162. package/dist/phaser/geom/util/matrix.d.ts +2 -2
  163. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  164. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  165. package/dist/phaser/geom/util/rectangle.d.ts +1 -1
  166. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  167. package/dist/phaser/util/math.d.ts.map +1 -1
  168. package/package.json +5 -4
  169. package/src/phaser/core/animation.ts +64 -60
  170. package/src/phaser/core/animation_manager.ts +54 -55
  171. package/src/phaser/core/animation_parser.ts +9 -9
  172. package/src/phaser/core/array_set.ts +16 -17
  173. package/src/phaser/core/cache.ts +92 -93
  174. package/src/phaser/core/const.ts +1 -1
  175. package/src/phaser/core/device.ts +24 -29
  176. package/src/phaser/core/device_util.ts +28 -32
  177. package/src/phaser/core/dom.ts +54 -65
  178. package/src/phaser/core/event_manager.ts +64 -94
  179. package/src/phaser/core/factory.ts +14 -14
  180. package/src/phaser/core/frame.ts +28 -28
  181. package/src/phaser/core/frame_data.test.ts +100 -0
  182. package/src/phaser/core/frame_data.ts +24 -24
  183. package/src/phaser/core/frame_util.ts +2 -2
  184. package/src/phaser/core/game.ts +50 -51
  185. package/src/phaser/core/input.ts +104 -110
  186. package/src/phaser/core/input_handler.test.ts +113 -0
  187. package/src/phaser/core/input_handler.ts +199 -218
  188. package/src/phaser/core/input_mouse.ts +71 -54
  189. package/src/phaser/core/input_mspointer.ts +52 -39
  190. package/src/phaser/core/input_pointer.ts +81 -80
  191. package/src/phaser/core/input_touch.ts +49 -36
  192. package/src/phaser/core/loader.ts +175 -154
  193. package/src/phaser/core/loader_parser.ts +39 -57
  194. package/src/phaser/core/raf.ts +8 -7
  195. package/src/phaser/core/registry.test.ts +31 -0
  196. package/src/phaser/core/registry.ts +9 -0
  197. package/src/phaser/core/scale_manager.ts +156 -152
  198. package/src/phaser/core/scene.ts +9 -13
  199. package/src/phaser/core/scene_manager.ts +47 -47
  200. package/src/phaser/core/signal.test.ts +4 -4
  201. package/src/phaser/core/signal.ts +41 -52
  202. package/src/phaser/core/signal_binding.ts +26 -25
  203. package/src/phaser/core/signal_dispatch.test.ts +180 -0
  204. package/src/phaser/core/sound.ts +75 -83
  205. package/src/phaser/core/sound_manager.ts +58 -56
  206. package/src/phaser/core/sound_sprite.ts +17 -16
  207. package/src/phaser/core/stage.ts +25 -24
  208. package/src/phaser/core/time.ts +52 -52
  209. package/src/phaser/core/timer.test.ts +187 -0
  210. package/src/phaser/core/timer.ts +82 -69
  211. package/src/phaser/core/timer_event.ts +10 -10
  212. package/src/phaser/core/tween.ts +90 -93
  213. package/src/phaser/core/tween_data.ts +45 -51
  214. package/src/phaser/core/tween_easing.test.ts +106 -0
  215. package/src/phaser/core/tween_easing.ts +151 -123
  216. package/src/phaser/core/tween_manager.ts +19 -18
  217. package/src/phaser/core/world.ts +4 -3
  218. package/src/phaser/display/bitmap_text.ts +56 -64
  219. package/src/phaser/display/button.ts +33 -32
  220. package/src/phaser/display/canvas/buffer.ts +8 -8
  221. package/src/phaser/display/canvas/graphics.ts +36 -37
  222. package/src/phaser/display/canvas/masker.ts +2 -2
  223. package/src/phaser/display/canvas/pool.test.ts +106 -0
  224. package/src/phaser/display/canvas/pool.ts +25 -27
  225. package/src/phaser/display/canvas/renderer.ts +32 -31
  226. package/src/phaser/display/canvas/tinter.ts +27 -27
  227. package/src/phaser/display/canvas/util.ts +7 -10
  228. package/src/phaser/display/display_object.ts +114 -118
  229. package/src/phaser/display/graphics.ts +121 -119
  230. package/src/phaser/display/graphics_data.ts +12 -12
  231. package/src/phaser/display/graphics_data_util.ts +2 -3
  232. package/src/phaser/display/group.ts +50 -57
  233. package/src/phaser/display/image.ts +55 -52
  234. package/src/phaser/display/sprite_batch.ts +3 -2
  235. package/src/phaser/display/sprite_util.ts +48 -54
  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
@@ -2,46 +2,40 @@ import { GROUP } from '../core/const.js';
2
2
  import { Signal } from '../core/signal.js';
3
3
  import { DisplayObject } from './display_object.js';
4
4
  import { Image } from './image.js';
5
+ import type { Game } from '../core/game.js';
5
6
 
6
7
  export const SORT_ASCENDING = -1;
7
8
  export const SORT_DESCENDING = 1;
8
9
 
9
10
  export class Group extends DisplayObject {
10
- declare z: number;
11
- ignoreDestroy!: boolean;
12
- pendingDestroy!: boolean;
13
- classType!: Function;
14
- cursor!: DisplayObject | null;
15
- inputEnableChildren!: boolean;
16
- onChildInputDown!: Signal;
17
- onChildInputUp!: Signal;
18
- onChildInputOver!: Signal;
19
- onChildInputOut!: Signal;
20
- onDestroy!: Signal;
21
- cursorIndex!: number;
22
- _sortProperty!: string;
23
- filters!: object[] | null;
11
+ declare public z: number;
12
+ public ignoreDestroy!: boolean;
13
+ public pendingDestroy!: boolean;
14
+ public classType!: Function;
15
+ public cursor!: DisplayObject | null;
16
+ public inputEnableChildren!: boolean;
17
+ public onChildInputDown!: Signal;
18
+ public onChildInputUp!: Signal;
19
+ public onChildInputOver!: Signal;
20
+ public onChildInputOut!: Signal;
21
+ public onDestroy!: Signal;
22
+ public cursorIndex!: number;
23
+ public _sortProperty!: string;
24
+ public filters!: object[] | null;
24
25
  /**
25
26
  * Creates a new Group object.
26
- * @param {import('../core/game.js').Game} game - The game instance this group belongs to.
27
+ * @param {Game} game - The game instance this group belongs to.
27
28
  * @param {DisplayObject} parent - The parent display object.
28
29
  * @param {string} name - The name of this group.
29
30
  * @param {boolean} addToStage - Whether to add this group to the stage.
30
31
  */
31
- constructor(
32
- game: import('../core/game.js').Game,
33
- parent: DisplayObject | null = null,
34
- name: string | null = null,
35
- addToStage: boolean = false
36
- ) {
32
+ public constructor(game: Game, parent: DisplayObject | null = null, name: string | null = null, addToStage = false) {
37
33
  super(game);
38
34
  /** @type {number} */
39
35
  this.type = GROUP;
40
- if (!parent) {
41
- parent = game.world;
42
- }
36
+ parent ??= game.world;
43
37
  /** @type {string} */
44
- this.name = name || 'group';
38
+ this.name = name ?? 'group';
45
39
  /** @type {number} */
46
40
  this.z = 0;
47
41
  if (addToStage) {
@@ -80,7 +74,7 @@ export class Group extends DisplayObject {
80
74
  * @param {boolean} destroyChildren - Whether to destroy children as well.
81
75
  * @param {boolean} soft - Whether to perform a soft destroy (leaving the group in the parent's children list).
82
76
  */
83
- override destroy(destroyChildren: boolean = true, soft: boolean = false) {
77
+ public override destroy(destroyChildren = true, soft = false) {
84
78
  if (this.game === null || this.ignoreDestroy) {
85
79
  return;
86
80
  }
@@ -106,7 +100,7 @@ export class Group extends DisplayObject {
106
100
  * @param {number} index - The index to add the child at.
107
101
  * @returns {T} The added child.
108
102
  */
109
- add<T extends DisplayObject>(child: T, silent: boolean = false, index: number = -1): T {
103
+ public add<T extends DisplayObject>(child: T, silent = false, index = -1): T {
110
104
  if (child.parent === this) {
111
105
  return child;
112
106
  }
@@ -124,9 +118,7 @@ export class Group extends DisplayObject {
124
118
  if (!silent && child.events) {
125
119
  child.events.onAddedToGroup$dispatch(child, this);
126
120
  }
127
- if (this.cursor === null) {
128
- this.cursor = child;
129
- }
121
+ this.cursor ??= child;
130
122
  return child;
131
123
  }
132
124
 
@@ -136,7 +128,7 @@ export class Group extends DisplayObject {
136
128
  * @param {number} index - The index to add the child at.
137
129
  * @param {boolean} silent - Whether to dispatch events.
138
130
  */
139
- addAt(child: DisplayObject, index: number, silent: boolean) {
131
+ public addAt(child: DisplayObject, index: number, silent: boolean) {
140
132
  this.add(child, silent, index);
141
133
  }
142
134
 
@@ -145,7 +137,7 @@ export class Group extends DisplayObject {
145
137
  * @param {number} index - The index of the child to get.
146
138
  * @returns {DisplayObject} The child at the specified index, or -1 if not found.
147
139
  */
148
- getAt(index: number) {
140
+ public getAt(index: number) {
149
141
  if (index < 0 || index >= this.children.length) {
150
142
  return -1;
151
143
  }
@@ -155,11 +147,11 @@ export class Group extends DisplayObject {
155
147
  /**
156
148
  * Updates the Z indices of all children in this group.
157
149
  */
158
- updateZ() {
150
+ public updateZ() {
159
151
  let i = this.children.length;
160
152
  while (i) {
161
153
  i -= 1;
162
- this.children[i].z = i;
154
+ this.children[i]!.z = i;
163
155
  }
164
156
  }
165
157
 
@@ -167,7 +159,7 @@ export class Group extends DisplayObject {
167
159
  * Gets the next child in this group (with circular wrapping).
168
160
  * @returns {DisplayObject} The next child, or null if no children exist.
169
161
  */
170
- next() {
162
+ public next() {
171
163
  if (this.cursor) {
172
164
  // Wrap the cursor?
173
165
  if (this.cursorIndex >= this.children.length - 1) {
@@ -175,7 +167,7 @@ export class Group extends DisplayObject {
175
167
  } else {
176
168
  this.cursorIndex += 1;
177
169
  }
178
- this.cursor = this.children[this.cursorIndex];
170
+ this.cursor = this.children[this.cursorIndex] ?? null;
179
171
  return this.cursor;
180
172
  }
181
173
  return null;
@@ -185,7 +177,7 @@ export class Group extends DisplayObject {
185
177
  * Gets the previous child in this group (with circular wrapping).
186
178
  * @returns {DisplayObject} The previous child, or null if no children exist.
187
179
  */
188
- previous() {
180
+ public previous() {
189
181
  if (this.cursor) {
190
182
  // Wrap the cursor?
191
183
  if (this.cursorIndex === 0) {
@@ -193,7 +185,7 @@ export class Group extends DisplayObject {
193
185
  } else {
194
186
  this.cursorIndex -= 1;
195
187
  }
196
- this.cursor = this.children[this.cursorIndex];
188
+ this.cursor = this.children[this.cursorIndex] ?? null;
197
189
  return this.cursor;
198
190
  }
199
191
  return null;
@@ -204,7 +196,7 @@ export class Group extends DisplayObject {
204
196
  * @param {DisplayObject} child1 - The first child to swap.
205
197
  * @param {DisplayObject} child2 - The second child to swap.
206
198
  */
207
- swap(child1: DisplayObject, child2: DisplayObject) {
199
+ public swap(child1: DisplayObject, child2: DisplayObject) {
208
200
  this.swapChildren(child1, child2);
209
201
  this.updateZ();
210
202
  }
@@ -214,7 +206,7 @@ export class Group extends DisplayObject {
214
206
  * @param {DisplayObject} child - The child to bring to the top.
215
207
  * @returns {DisplayObject} The child that was brought to the top.
216
208
  */
217
- bringToTop(child: DisplayObject) {
209
+ public bringToTop(child: DisplayObject) {
218
210
  if (child.parent === this && this.getIndex(child) < this.children.length) {
219
211
  this.remove(child, false, true);
220
212
  this.add(child, true);
@@ -227,7 +219,7 @@ export class Group extends DisplayObject {
227
219
  * @param {DisplayObject} child - The child to send to the back.
228
220
  * @returns {DisplayObject} The child that was sent to the back.
229
221
  */
230
- sendToBack(child: DisplayObject) {
222
+ public sendToBack(child: DisplayObject) {
231
223
  if (child.parent === this && this.getIndex(child) > 0) {
232
224
  this.remove(child, false, true);
233
225
  this.addAt(child, 0, true);
@@ -238,7 +230,7 @@ export class Group extends DisplayObject {
238
230
  /**
239
231
  * Reverses the order of children in this group.
240
232
  */
241
- reverse() {
233
+ public reverse() {
242
234
  this.children.reverse();
243
235
  this.updateZ();
244
236
  }
@@ -248,14 +240,14 @@ export class Group extends DisplayObject {
248
240
  * @param {DisplayObject} child - The child to get the index of.
249
241
  * @returns {number} The index of the child, or -1 if not found.
250
242
  */
251
- getIndex(child: DisplayObject) {
243
+ public getIndex(child: DisplayObject) {
252
244
  return this.children.indexOf(child);
253
245
  }
254
246
 
255
247
  /**
256
248
  * Updates the Z indices of all children in this group before the update cycle.
257
249
  */
258
- override preUpdate() {
250
+ public override preUpdate() {
259
251
  if (this.pendingDestroy) {
260
252
  this.destroy();
261
253
  return;
@@ -264,28 +256,28 @@ export class Group extends DisplayObject {
264
256
  this.renderOrderID = -1;
265
257
  return;
266
258
  }
267
- for (let i = 0; i < this.children.length; i += 1) {
268
- this.children[i].preUpdate();
259
+ for (const child of this.children) {
260
+ child.preUpdate();
269
261
  }
270
262
  }
271
263
 
272
264
  /**
273
265
  * Updates all children in this group during the update cycle.
274
266
  */
275
- override update() {
267
+ public override update() {
276
268
  let i = this.children.length;
277
269
  while (i) {
278
270
  i -= 1;
279
- this.children[i].update();
271
+ this.children[i]!.update();
280
272
  }
281
273
  }
282
274
 
283
275
  /**
284
276
  * Updates all children in this group after the update cycle.
285
277
  */
286
- override postUpdate() {
287
- for (let i = 0; i < this.children.length; i += 1) {
288
- this.children[i].postUpdate();
278
+ public override postUpdate() {
279
+ for (const child of this.children) {
280
+ child.postUpdate();
289
281
  }
290
282
  }
291
283
 
@@ -296,8 +288,8 @@ export class Group extends DisplayObject {
296
288
  * @param {boolean} silent - Whether to dispatch events.
297
289
  * @returns {boolean} True if the child was removed, false otherwise.
298
290
  */
299
- remove(child: any, destroy: boolean = true, silent: boolean = false) {
300
- if (this.children.length === 0 || this.children.indexOf(child) === -1) {
291
+ public remove(child: any, destroy = true, silent = false) {
292
+ if (this.children.length === 0 || !this.children.includes(child)) {
301
293
  return false;
302
294
  }
303
295
  if (!silent && child.events && !child.destroyPhase) {
@@ -320,15 +312,16 @@ export class Group extends DisplayObject {
320
312
  * @param {boolean} silent - Whether to dispatch events.
321
313
  * @param {boolean} destroyTexture - Whether to destroy textures as well.
322
314
  */
323
- removeAll(destroy: boolean = true, silent: boolean = false, destroyTexture: boolean = false) {
315
+ public removeAll(destroy = true, silent = false, destroyTexture = false) {
324
316
  if (this.children.length === 0) {
325
317
  return;
326
318
  }
327
319
  do {
328
- if (!silent && this.children[0].events) {
329
- this.children[0].events.onRemovedFromGroup$dispatch(this.children[0], this);
320
+ const first = this.children[0]!;
321
+ if (!silent && first.events) {
322
+ first.events.onRemovedFromGroup$dispatch(first, this);
330
323
  }
331
- const removed = this.removeChild(this.children[0]);
324
+ const removed = this.removeChild(first);
332
325
  if (destroy && removed) {
333
326
  (removed as any).destroy(true, destroyTexture);
334
327
  }
@@ -6,37 +6,40 @@ import { clone } from '../geom/util/rectangle.js';
6
6
  import { DisplayObject } from './display_object.js';
7
7
  import { getBounds, getLocalBounds, renderCanvas, renderWebGL, setTexture } from './sprite_util.js';
8
8
  import { Texture } from './webgl/texture.js';
9
+ import type { Game } from '../core/game.js';
10
+ import type { Frame } from '../core/frame.js';
11
+ import type { Matrix } from '../geom/matrix.js';
9
12
 
10
13
  export class Image extends DisplayObject {
11
- key!: any;
12
- texture!: Texture;
13
- declare _width: number;
14
- declare _height: number;
15
- tint!: number;
16
- cachedTint!: number;
17
- tilingTexture!: Texture | null;
18
- tintedTexture!: Texture | null;
19
- blendMode!: number;
20
- shader!: object | null;
21
- _frame!: any;
22
- pendingDestroy!: boolean;
23
- declare events: EventManager;
24
- animations!: AnimationManager;
25
- customRender!: boolean;
26
- cropRect!: Rectangle | null;
27
- _crop!: Rectangle | null;
28
- refreshTexture!: boolean;
29
- declare renderOrderID: number;
14
+ public key!: any;
15
+ public texture!: Texture;
16
+ declare public _width: number;
17
+ declare public _height: number;
18
+ public tint!: number;
19
+ public cachedTint!: number;
20
+ public tilingTexture!: Texture | null;
21
+ public tintedTexture!: Texture | null;
22
+ public blendMode!: number;
23
+ public shader!: object | null;
24
+ public _frame!: any;
25
+ public pendingDestroy!: boolean;
26
+ declare public events: EventManager;
27
+ public animations!: AnimationManager;
28
+ public customRender!: boolean;
29
+ public cropRect!: Rectangle | null;
30
+ public _crop!: Rectangle | null;
31
+ public refreshTexture!: boolean;
32
+ declare public renderOrderID: number;
30
33
  /**
31
34
  * Creates a new Image instance.
32
- * @param {import('../core/game.js').Game} game - The game instance this image belongs to.
35
+ * @param {Game} game - The game instance this image belongs to.
33
36
  * @param {number} x - The x position of the image.
34
37
  * @param {number} y - The y position of the image.
35
38
  * @param {string | number | Texture} key - The texture key or texture to use.
36
39
  * @param {string | number} frame - The frame identifier (name or index) to use.
37
40
  */
38
- constructor(
39
- game: import('../core/game.js').Game,
41
+ public constructor(
42
+ game: Game,
40
43
  x: number,
41
44
  y: number,
42
45
  key: string | number | Texture | null,
@@ -49,7 +52,7 @@ export class Image extends DisplayObject {
49
52
  this.renderable = true;
50
53
  /** @type {string | number | Texture} */
51
54
  this.key = key;
52
- this.texture = window.PhaserRegistry.CACHE_MISSING_IMAGE;
55
+ this.texture = globalThis.PhaserRegistry.CACHE_MISSING_IMAGE;
53
56
  /** @type {object} */
54
57
  this.data = {};
55
58
  /** @type {number} */
@@ -84,7 +87,7 @@ export class Image extends DisplayObject {
84
87
  /**
85
88
  * Destroys this image and cleans up resources.
86
89
  */
87
- override destroy() {
90
+ public override destroy() {
88
91
  this.game = null!;
89
92
  this.key = null;
90
93
  this.data = null;
@@ -108,7 +111,7 @@ export class Image extends DisplayObject {
108
111
  /**
109
112
  * Called before the update cycle for this image.
110
113
  */
111
- override preUpdate() {
114
+ public override preUpdate() {
112
115
  if (this.pendingDestroy) {
113
116
  this.destroy();
114
117
  return;
@@ -124,8 +127,8 @@ export class Image extends DisplayObject {
124
127
  if (this.animations) {
125
128
  this.animations.update();
126
129
  }
127
- for (let i = 0; i < this.children.length; i += 1) {
128
- this.children[i].preUpdate();
130
+ for (const child of this.children) {
131
+ child.preUpdate();
129
132
  }
130
133
  }
131
134
 
@@ -137,12 +140,12 @@ export class Image extends DisplayObject {
137
140
  * @param {string | number | null | undefined} frame - The frame identifier (name or index) to use.
138
141
  * @param {boolean} stopAnimation - Whether to stop the animation when changing textures.
139
142
  */
140
- loadTexture(key: string | number | Texture | null, frame: string | number | null = 0, stopAnimation: boolean = true) {
143
+ public loadTexture(key: string | number | Texture | null, frame: string | number | null = 0, stopAnimation = true) {
141
144
  if (key === PENDING_ATLAS) {
142
145
  key = frame ?? 0;
143
146
  frame = 0;
144
147
  } else {
145
- frame = frame || 0;
148
+ frame = frame ?? 0;
146
149
  }
147
150
  if (stopAnimation) {
148
151
  this.animations.stop();
@@ -177,9 +180,9 @@ export class Image extends DisplayObject {
177
180
 
178
181
  /**
179
182
  * Sets the current frame of this image.
180
- * @param {import('../core/frame.js').Frame} frame - The frame to set.
183
+ * @param {Frame} frame - The frame to set.
181
184
  */
182
- setFrame(frame: import('../core/frame.js').Frame) {
185
+ public setFrame(frame: Frame) {
183
186
  this._frame = frame;
184
187
  this.texture.frame.x = frame.x;
185
188
  this.texture.frame.y = frame.y;
@@ -226,7 +229,7 @@ export class Image extends DisplayObject {
226
229
  * @param {number} width - The new width of the frame.
227
230
  * @param {number} height - The new height of the frame.
228
231
  */
229
- resizeFrame(_parent: DisplayObject, width: number, height: number) {
232
+ public resizeFrame(_parent: DisplayObject, width: number, height: number) {
230
233
  this.texture.frame.resize(width, height);
231
234
  this.texture.setFrame(this.texture.frame);
232
235
  }
@@ -234,7 +237,7 @@ export class Image extends DisplayObject {
234
237
  /**
235
238
  * Resets the frame of this image to its original frame.
236
239
  */
237
- resetFrame() {
240
+ public resetFrame() {
238
241
  if (this._frame) {
239
242
  this.setFrame(this._frame);
240
243
  }
@@ -244,7 +247,7 @@ export class Image extends DisplayObject {
244
247
  * Gets the current frame index of this image.
245
248
  * @returns {number} The current frame index.
246
249
  */
247
- get frame() {
250
+ public get frame() {
248
251
  return this.animations.frame;
249
252
  }
250
253
 
@@ -252,7 +255,7 @@ export class Image extends DisplayObject {
252
255
  * Sets the current frame index of this image.
253
256
  * @param {number} value - The new frame index to set.
254
257
  */
255
- set frame(value: number) {
258
+ public set frame(value: number) {
256
259
  this.animations.frame = value;
257
260
  }
258
261
 
@@ -260,7 +263,7 @@ export class Image extends DisplayObject {
260
263
  * Gets the current frame name of this image.
261
264
  * @returns {string} The current frame name.
262
265
  */
263
- get frameName() {
266
+ public get frameName() {
264
267
  return this.animations.frameName;
265
268
  }
266
269
 
@@ -268,7 +271,7 @@ export class Image extends DisplayObject {
268
271
  * Sets the current frame name of this image.
269
272
  * @param {string} value - The new frame name to set.
270
273
  */
271
- set frameName(value: string) {
274
+ public set frameName(value: string) {
272
275
  this.animations.frameName = value;
273
276
  }
274
277
 
@@ -279,7 +282,7 @@ export class Image extends DisplayObject {
279
282
  * @param {Rectangle} rect - The rectangle to crop to.
280
283
  * @param {boolean} copy - Whether to copy the rect or use it directly.
281
284
  */
282
- crop(rect: Rectangle, copy: boolean = false) {
285
+ public crop(rect: Rectangle, copy = false) {
283
286
  if (rect) {
284
287
  if (copy && this.cropRect !== null) {
285
288
  this.cropRect.setTo(rect.x, rect.y, rect.width, rect.height);
@@ -299,7 +302,7 @@ export class Image extends DisplayObject {
299
302
  /**
300
303
  * Updates the crop rectangle of this image.
301
304
  */
302
- updateCrop() {
305
+ public updateCrop() {
303
306
  if (!this.cropRect) {
304
307
  return;
305
308
  }
@@ -332,7 +335,7 @@ export class Image extends DisplayObject {
332
335
  * Gets the width of this image.
333
336
  * @returns {number} The width in pixels.
334
337
  */
335
- override get width() {
338
+ public override get width() {
336
339
  return this.scale.x * this.texture.frame.width;
337
340
  }
338
341
 
@@ -340,7 +343,7 @@ export class Image extends DisplayObject {
340
343
  * Sets the width of this image.
341
344
  * @param {number} value - The new width in pixels.
342
345
  */
343
- override set width(value: number) {
346
+ public override set width(value: number) {
344
347
  this.scale.x = value / this.texture.frame.width;
345
348
  this._width = value;
346
349
  }
@@ -349,7 +352,7 @@ export class Image extends DisplayObject {
349
352
  * Gets the height of this image.
350
353
  * @returns {number} The height in pixels.
351
354
  */
352
- override get height() {
355
+ public override get height() {
353
356
  return this.scale.y * this.texture.frame.height;
354
357
  }
355
358
 
@@ -357,7 +360,7 @@ export class Image extends DisplayObject {
357
360
  * Sets the height of this image.
358
361
  * @param {number} value - The new height in pixels.
359
362
  */
360
- override set height(value: number) {
363
+ public override set height(value: number) {
361
364
  this.scale.y = value / this.texture.frame.height;
362
365
  this._height = value;
363
366
  }
@@ -365,7 +368,7 @@ export class Image extends DisplayObject {
365
368
  /**
366
369
  * Called when the texture of this image is updated.
367
370
  */
368
- onTextureUpdate() {
371
+ public onTextureUpdate() {
369
372
  // So if _width is 0 then width was not set..
370
373
  if (this._width) {
371
374
  this.scale.x = this._width / this.texture.frame.width;
@@ -380,16 +383,16 @@ export class Image extends DisplayObject {
380
383
  * @param {Texture} texture - The new texture to set.
381
384
  * @param {boolean} destroyBase - Whether to destroy the base texture.
382
385
  */
383
- setTexture(texture: Texture, destroyBase: boolean = false) {
386
+ public setTexture(texture: Texture, destroyBase = false) {
384
387
  setTexture(this, texture, destroyBase);
385
388
  }
386
389
 
387
390
  /**
388
391
  * Gets the bounds of this image.
389
- * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
392
+ * @param {Matrix} matrix - The transformation matrix to use.
390
393
  * @returns {Rectangle} The bounds rectangle of this image.
391
394
  */
392
- override getBounds(matrix: import('../geom/matrix.js').Matrix | null = null) {
395
+ public override getBounds(matrix: Matrix | null = null) {
393
396
  return getBounds(this, matrix);
394
397
  }
395
398
 
@@ -397,25 +400,25 @@ export class Image extends DisplayObject {
397
400
  * Gets the local bounds of this image.
398
401
  * @returns {Rectangle} The local bounds rectangle of this image.
399
402
  */
400
- override getLocalBounds() {
403
+ public override getLocalBounds() {
401
404
  return getLocalBounds(this);
402
405
  }
403
406
 
404
407
  /**
405
408
  * Renders this image using WebGL.
406
409
  * @param {object} renderSession - The WebGL rendering session.
407
- * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
410
+ * @param {Matrix} matrix - The transformation matrix to use.
408
411
  */
409
- override renderWebGL(renderSession: any, matrix: import('../geom/matrix.js').Matrix | null = null) {
412
+ public override renderWebGL(renderSession: any, matrix: Matrix | null = null) {
410
413
  renderWebGL(this, renderSession, matrix);
411
414
  }
412
415
 
413
416
  /**
414
417
  * Renders this image using Canvas.
415
418
  * @param {object} renderSession - The Canvas rendering session.
416
- * @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
419
+ * @param {Matrix} matrix - The transformation matrix to use.
417
420
  */
418
- override renderCanvas(renderSession: any, matrix: import('../geom/matrix.js').Matrix | null = null) {
421
+ public override renderCanvas(renderSession: any, matrix: Matrix | null = null) {
419
422
  renderCanvas(this, renderSession, matrix);
420
423
  }
421
424
  }
@@ -1,11 +1,12 @@
1
1
  import { DisplayObject } from './display_object.js';
2
+ import type { Game } from '../core/game.js';
2
3
 
3
4
  export class SpriteBatch extends DisplayObject {
4
5
  /**
5
6
  * Creates a new SpriteBatch object.
6
- * @param {import('../core/game.js').Game} game - The game instance.
7
+ * @param {Game} game - The game instance.
7
8
  */
8
- constructor(game: import('../core/game.js').Game) {
9
+ public constructor(game: Game) {
9
10
  super(game);
10
11
  }
11
12
  }