@vpmedia/phaser 1.115.0 → 1.117.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 (193) hide show
  1. package/dist/index.js +56 -96
  2. package/dist/index.js.map +1 -1
  3. package/dist/phaser/core/animation.d.ts.map +1 -1
  4. package/dist/phaser/core/animation_manager.d.ts +15 -14
  5. package/dist/phaser/core/animation_manager.d.ts.map +1 -1
  6. package/dist/phaser/core/animation_parser.d.ts.map +1 -1
  7. package/dist/phaser/core/array_set.d.ts.map +1 -1
  8. package/dist/phaser/core/cache.d.ts +10 -9
  9. package/dist/phaser/core/cache.d.ts.map +1 -1
  10. package/dist/phaser/core/device_util.d.ts.map +1 -1
  11. package/dist/phaser/core/dom.d.ts.map +1 -1
  12. package/dist/phaser/core/factory.d.ts.map +1 -1
  13. package/dist/phaser/core/game.d.ts.map +1 -1
  14. package/dist/phaser/core/input.d.ts +20 -20
  15. package/dist/phaser/core/input.d.ts.map +1 -1
  16. package/dist/phaser/core/input_handler.d.ts +11 -13
  17. package/dist/phaser/core/input_handler.d.ts.map +1 -1
  18. package/dist/phaser/core/input_mouse.d.ts.map +1 -1
  19. package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
  20. package/dist/phaser/core/input_pointer.d.ts +19 -8
  21. package/dist/phaser/core/input_pointer.d.ts.map +1 -1
  22. package/dist/phaser/core/input_touch.d.ts.map +1 -1
  23. package/dist/phaser/core/loader.d.ts.map +1 -1
  24. package/dist/phaser/core/raf.d.ts.map +1 -1
  25. package/dist/phaser/core/scale_manager.d.ts +38 -13
  26. package/dist/phaser/core/scale_manager.d.ts.map +1 -1
  27. package/dist/phaser/core/scene.d.ts.map +1 -1
  28. package/dist/phaser/core/scene_manager.d.ts.map +1 -1
  29. package/dist/phaser/core/signal.d.ts.map +1 -1
  30. package/dist/phaser/core/signal_binding.d.ts.map +1 -1
  31. package/dist/phaser/core/sound.d.ts +2 -2
  32. package/dist/phaser/core/sound.d.ts.map +1 -1
  33. package/dist/phaser/core/sound_manager.d.ts +24 -22
  34. package/dist/phaser/core/sound_manager.d.ts.map +1 -1
  35. package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
  36. package/dist/phaser/core/stage.d.ts.map +1 -1
  37. package/dist/phaser/core/time.d.ts.map +1 -1
  38. package/dist/phaser/core/timer.d.ts +1 -1
  39. package/dist/phaser/core/timer.d.ts.map +1 -1
  40. package/dist/phaser/core/tween.d.ts.map +1 -1
  41. package/dist/phaser/core/tween_data.d.ts +26 -26
  42. package/dist/phaser/core/tween_data.d.ts.map +1 -1
  43. package/dist/phaser/core/tween_manager.d.ts.map +1 -1
  44. package/dist/phaser/core/world.d.ts.map +1 -1
  45. package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
  46. package/dist/phaser/display/button.d.ts.map +1 -1
  47. package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
  48. package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
  49. package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
  50. package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
  51. package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
  52. package/dist/phaser/display/canvas/tinter.d.ts +3 -2
  53. package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
  54. package/dist/phaser/display/canvas/util.d.ts.map +1 -1
  55. package/dist/phaser/display/display_object.d.ts.map +1 -1
  56. package/dist/phaser/display/graphics.d.ts.map +1 -1
  57. package/dist/phaser/display/graphics_data.d.ts.map +1 -1
  58. package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
  59. package/dist/phaser/display/group.d.ts.map +1 -1
  60. package/dist/phaser/display/image.d.ts +2 -2
  61. package/dist/phaser/display/image.d.ts.map +1 -1
  62. package/dist/phaser/display/sprite_util.d.ts.map +1 -1
  63. package/dist/phaser/display/text.d.ts.map +1 -1
  64. package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  65. package/dist/phaser/display/webgl/base_texture.d.ts +12 -10
  66. package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
  67. package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  68. package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
  69. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +13 -12
  70. package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  71. package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  72. package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  73. package/dist/phaser/display/webgl/graphics.d.ts +9 -7
  74. package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
  75. package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  76. package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  77. package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
  78. package/dist/phaser/display/webgl/renderer.d.ts +12 -10
  79. package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
  80. package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  81. package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  82. package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  83. package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  84. package/dist/phaser/display/webgl/texture.d.ts +18 -33
  85. package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
  86. package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
  87. package/dist/phaser/display/webgl/util.d.ts.map +1 -1
  88. package/dist/phaser/geom/circle.d.ts.map +1 -1
  89. package/dist/phaser/geom/ellipse.d.ts.map +1 -1
  90. package/dist/phaser/geom/line.d.ts.map +1 -1
  91. package/dist/phaser/geom/matrix.d.ts +1 -1
  92. package/dist/phaser/geom/matrix.d.ts.map +1 -1
  93. package/dist/phaser/geom/point.d.ts.map +1 -1
  94. package/dist/phaser/geom/polygon.d.ts.map +1 -1
  95. package/dist/phaser/geom/rectangle.d.ts.map +1 -1
  96. package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  97. package/dist/phaser/geom/util/circle.d.ts.map +1 -1
  98. package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
  99. package/dist/phaser/geom/util/line.d.ts +5 -4
  100. package/dist/phaser/geom/util/line.d.ts.map +1 -1
  101. package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
  102. package/dist/phaser/geom/util/point.d.ts.map +1 -1
  103. package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
  104. package/dist/phaser/geom/util/rectangle.d.ts +10 -1
  105. package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
  106. package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/phaser/core/animation.ts +20 -20
  109. package/src/phaser/core/animation_manager.ts +27 -24
  110. package/src/phaser/core/animation_parser.ts +2 -2
  111. package/src/phaser/core/array_set.ts +7 -7
  112. package/src/phaser/core/cache.ts +55 -51
  113. package/src/phaser/core/callback_context.test.ts +70 -0
  114. package/src/phaser/core/device_util.ts +13 -13
  115. package/src/phaser/core/dom.ts +26 -22
  116. package/src/phaser/core/factory.ts +6 -6
  117. package/src/phaser/core/game.ts +10 -10
  118. package/src/phaser/core/input.ts +37 -39
  119. package/src/phaser/core/input_handler.ts +90 -93
  120. package/src/phaser/core/input_mouse.ts +19 -19
  121. package/src/phaser/core/input_mspointer.ts +15 -15
  122. package/src/phaser/core/input_pointer.ts +37 -28
  123. package/src/phaser/core/input_touch.ts +17 -17
  124. package/src/phaser/core/loader.ts +52 -52
  125. package/src/phaser/core/loader_parser.ts +3 -3
  126. package/src/phaser/core/raf.ts +3 -3
  127. package/src/phaser/core/scale_manager.ts +86 -67
  128. package/src/phaser/core/scene.ts +7 -7
  129. package/src/phaser/core/scene_manager.ts +16 -16
  130. package/src/phaser/core/signal.ts +29 -19
  131. package/src/phaser/core/signal_binding.ts +4 -4
  132. package/src/phaser/core/sound.ts +17 -17
  133. package/src/phaser/core/sound_manager.ts +71 -72
  134. package/src/phaser/core/sound_sprite.ts +1 -1
  135. package/src/phaser/core/stage.ts +7 -7
  136. package/src/phaser/core/time.ts +16 -16
  137. package/src/phaser/core/timer.ts +36 -26
  138. package/src/phaser/core/tween.ts +23 -23
  139. package/src/phaser/core/tween_data.ts +41 -37
  140. package/src/phaser/core/tween_manager.ts +11 -11
  141. package/src/phaser/core/world.ts +1 -1
  142. package/src/phaser/display/bitmap_text.ts +13 -13
  143. package/src/phaser/display/button.ts +13 -13
  144. package/src/phaser/display/canvas/buffer.ts +3 -3
  145. package/src/phaser/display/canvas/graphics.ts +3 -3
  146. package/src/phaser/display/canvas/masker.ts +2 -2
  147. package/src/phaser/display/canvas/pool.ts +6 -6
  148. package/src/phaser/display/canvas/renderer.ts +6 -6
  149. package/src/phaser/display/canvas/tinter.ts +39 -8
  150. package/src/phaser/display/canvas/util.ts +15 -9
  151. package/src/phaser/display/display_object.ts +38 -38
  152. package/src/phaser/display/graphics.ts +30 -30
  153. package/src/phaser/display/graphics_data.ts +1 -1
  154. package/src/phaser/display/graphics_data_util.ts +1 -1
  155. package/src/phaser/display/group.ts +16 -16
  156. package/src/phaser/display/image.ts +30 -26
  157. package/src/phaser/display/sprite_util.ts +12 -4
  158. package/src/phaser/display/text.ts +55 -55
  159. package/src/phaser/display/webgl/abstract_filter.ts +1 -1
  160. package/src/phaser/display/webgl/base_texture.ts +22 -18
  161. package/src/phaser/display/webgl/blend_manager.ts +3 -3
  162. package/src/phaser/display/webgl/earcut.ts +3 -3
  163. package/src/phaser/display/webgl/fast_sprite_batch.ts +26 -24
  164. package/src/phaser/display/webgl/filter_manager.ts +7 -7
  165. package/src/phaser/display/webgl/filter_texture.ts +3 -3
  166. package/src/phaser/display/webgl/graphics.ts +43 -41
  167. package/src/phaser/display/webgl/graphics_data.ts +2 -2
  168. package/src/phaser/display/webgl/mask_manager.ts +2 -2
  169. package/src/phaser/display/webgl/render_texture.ts +6 -6
  170. package/src/phaser/display/webgl/renderer.ts +20 -25
  171. package/src/phaser/display/webgl/shader/normal.ts +3 -3
  172. package/src/phaser/display/webgl/shader_manager.ts +2 -2
  173. package/src/phaser/display/webgl/sprite_batch.ts +9 -9
  174. package/src/phaser/display/webgl/stencil_manager.ts +4 -4
  175. package/src/phaser/display/webgl/texture.ts +23 -42
  176. package/src/phaser/display/webgl/texture_util.ts +2 -2
  177. package/src/phaser/display/webgl/util.ts +11 -7
  178. package/src/phaser/geom/circle.ts +21 -21
  179. package/src/phaser/geom/ellipse.ts +7 -7
  180. package/src/phaser/geom/line.ts +29 -29
  181. package/src/phaser/geom/matrix.ts +13 -13
  182. package/src/phaser/geom/point.ts +36 -30
  183. package/src/phaser/geom/polygon.ts +6 -6
  184. package/src/phaser/geom/rectangle.ts +42 -42
  185. package/src/phaser/geom/rounded_rectangle.ts +2 -2
  186. package/src/phaser/geom/util/circle.ts +7 -7
  187. package/src/phaser/geom/util/ellipse.ts +1 -1
  188. package/src/phaser/geom/util/line.ts +13 -5
  189. package/src/phaser/geom/util/matrix.ts +3 -3
  190. package/src/phaser/geom/util/point.ts +20 -20
  191. package/src/phaser/geom/util/polygon.ts +1 -1
  192. package/src/phaser/geom/util/rectangle.ts +34 -17
  193. package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
@@ -121,7 +121,7 @@ export class DisplayObject {
121
121
  /**
122
122
  * Destroys this display object and cleans up resources.
123
123
  */
124
- public destroy() {
124
+ public destroy(): void {
125
125
  if (this.children) {
126
126
  let i = this.children.length;
127
127
  while (i) {
@@ -157,7 +157,7 @@ export class DisplayObject {
157
157
  * @param {DisplayObject} child - The child display object to add.
158
158
  * @returns {DisplayObject} The added child display object.
159
159
  */
160
- public addChild(child: DisplayObject) {
160
+ public addChild(child: DisplayObject): DisplayObject {
161
161
  return this.addChildAt(child, this.children.length);
162
162
  }
163
163
 
@@ -168,7 +168,7 @@ export class DisplayObject {
168
168
  * @returns {DisplayObject} The added child display object.
169
169
  * @throws {Error} If the index is out of bounds.
170
170
  */
171
- public addChildAt(child: DisplayObject, index: number) {
171
+ public addChildAt(child: DisplayObject, index: number): DisplayObject {
172
172
  if (index >= 0 && index <= this.children.length) {
173
173
  if (child.parent) {
174
174
  child.parent.removeChild(child);
@@ -186,7 +186,7 @@ export class DisplayObject {
186
186
  * @param {DisplayObject} child2 - The second child display object.
187
187
  * @throws {Error} If either child is not a child of this container.
188
188
  */
189
- public swapChildren(child: DisplayObject, child2: DisplayObject) {
189
+ public swapChildren(child: DisplayObject, child2: DisplayObject): void {
190
190
  if (child === child2) {
191
191
  return;
192
192
  }
@@ -205,7 +205,7 @@ export class DisplayObject {
205
205
  * @returns {number} The index of the child in the children list.
206
206
  * @throws {Error} If the child is not a child of this container.
207
207
  */
208
- public getChildIndex(child: DisplayObject) {
208
+ public getChildIndex(child: DisplayObject): number {
209
209
  const index = this.children.indexOf(child);
210
210
  if (index === -1) {
211
211
  throw new Error('The supplied DisplayObject must be a child of the caller');
@@ -219,7 +219,7 @@ export class DisplayObject {
219
219
  * @param {number} index - The new index for the child.
220
220
  * @throws {Error} If the index is out of bounds.
221
221
  */
222
- public setChildIndex(child: DisplayObject, index: number) {
222
+ public setChildIndex(child: DisplayObject, index: number): void {
223
223
  if (index < 0 || index >= this.children.length) {
224
224
  throw new Error('The supplied index is out of bounds');
225
225
  }
@@ -234,7 +234,7 @@ export class DisplayObject {
234
234
  * @returns {DisplayObject} The child display object at the specified index.
235
235
  * @throws {Error} If the index is out of bounds.
236
236
  */
237
- public getChildAt(index: number) {
237
+ public getChildAt(index: number): DisplayObject | undefined {
238
238
  if (index < 0 || index >= this.children.length) {
239
239
  throw new Error(
240
240
  `getChildAt: Supplied index ${
@@ -250,7 +250,7 @@ export class DisplayObject {
250
250
  * @param {DisplayObject} child - The child display object to remove.
251
251
  * @returns {DisplayObject} The removed child display object.
252
252
  */
253
- public removeChild(child: DisplayObject) {
253
+ public removeChild(child: DisplayObject): DisplayObject | null | undefined {
254
254
  const index = this.children.indexOf(child);
255
255
  if (index === -1) {
256
256
  return null;
@@ -263,7 +263,7 @@ export class DisplayObject {
263
263
  * @param {number} index - The index of the child to remove.
264
264
  * @returns {DisplayObject} The removed child display object.
265
265
  */
266
- public removeChildAt(index: number) {
266
+ public removeChildAt(index: number): DisplayObject | undefined {
267
267
  const child = this.getChildAt(index);
268
268
  if (child) {
269
269
  child.parent = null;
@@ -279,7 +279,7 @@ export class DisplayObject {
279
279
  * @returns {DisplayObject[]} The array of removed child display objects.
280
280
  * @throws {Error} If the range is invalid.
281
281
  */
282
- public removeChildren(beginIndex: number, endIndex: number) {
282
+ public removeChildren(beginIndex: number, endIndex: number): DisplayObject[] {
283
283
  beginIndex ??= 0;
284
284
  endIndex ??= this.children.length;
285
285
  const range = endIndex - beginIndex;
@@ -301,7 +301,7 @@ export class DisplayObject {
301
301
  * @param {DisplayObject | null | undefined} parent - The parent display object to use for the world transform calculation.
302
302
  * @returns {DisplayObject} This DisplayObject instance for chaining.
303
303
  */
304
- public updateTransform(parent: DisplayObject | null | undefined = null) {
304
+ public updateTransform(parent: DisplayObject | null | undefined = null): this {
305
305
  if (!parent && !this.parent) {
306
306
  return this;
307
307
  }
@@ -384,7 +384,7 @@ export class DisplayObject {
384
384
  * @param {DisplayObject} targetCoordinateSpace - The coordinate space to calculate bounds in.
385
385
  * @returns {Rectangle} The bounds rectangle of this display object.
386
386
  */
387
- public getBounds(targetCoordinateSpace?: any) {
387
+ public getBounds(targetCoordinateSpace?: any): Rectangle {
388
388
  const isTargetCoordinateSpaceDisplayObject = targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
389
389
  let isTargetCoordinateSpaceThisOrParent = true;
390
390
  if (!isTargetCoordinateSpaceDisplayObject) {
@@ -485,7 +485,7 @@ export class DisplayObject {
485
485
  * Gets the bounds of this display object in local coordinates.
486
486
  * @returns {Rectangle} The bounds rectangle of this display object in local space.
487
487
  */
488
- public getLocalBounds() {
488
+ public getLocalBounds(): Rectangle {
489
489
  return this.getBounds(this);
490
490
  }
491
491
 
@@ -509,7 +509,7 @@ export class DisplayObject {
509
509
  * @param {object} renderSession - The WebGL rendering session.
510
510
  * @param {Matrix | null} _matrix - The transform matrix to render with.
511
511
  */
512
- public renderWebGL(renderSession: RenderSession, _matrix: Matrix | null = null) {
512
+ public renderWebGL(renderSession: RenderSession, _matrix: Matrix | null = null): void {
513
513
  if (!this.visible || this.alpha <= 0) {
514
514
  return;
515
515
  }
@@ -546,7 +546,7 @@ export class DisplayObject {
546
546
  * Renders this display object using Canvas.
547
547
  * @param {object} renderSession - The Canvas rendering session.
548
548
  */
549
- public renderCanvas(renderSession: RenderSession) {
549
+ public renderCanvas(renderSession: RenderSession): void {
550
550
  if (!this.visible || this.alpha <= 0) {
551
551
  return;
552
552
  }
@@ -564,21 +564,21 @@ export class DisplayObject {
564
564
  /**
565
565
  * Called before the update cycle for this display object.
566
566
  */
567
- public preUpdate() {
567
+ public preUpdate(): void {
568
568
  // Override
569
569
  }
570
570
 
571
571
  /**
572
572
  * Called during the update cycle for this display object.
573
573
  */
574
- public update() {
574
+ public update(): void {
575
575
  // Override
576
576
  }
577
577
 
578
578
  /**
579
579
  * Called after the update cycle for this display object.
580
580
  */
581
- public postUpdate() {
581
+ public postUpdate(): void {
582
582
  // Override
583
583
  }
584
584
 
@@ -586,7 +586,7 @@ export class DisplayObject {
586
586
  * Generates a texture for this display object.
587
587
  * @throws {Error} This method is not implemented yet.
588
588
  */
589
- public generateTexture() {
589
+ public generateTexture(): void {
590
590
  // TODO
591
591
  throw new Error('display_object.generateTexture() is not implemented');
592
592
  }
@@ -596,7 +596,7 @@ export class DisplayObject {
596
596
  * @param {Point} position - The local position to convert.
597
597
  * @returns {Point} The converted global position.
598
598
  */
599
- public toGlobal(position: Point) {
599
+ public toGlobal(position: Point): Point {
600
600
  this.updateTransform();
601
601
  return this.worldTransform.apply(position);
602
602
  }
@@ -607,7 +607,7 @@ export class DisplayObject {
607
607
  * @param {DisplayObject} from - The display object to convert from (defaults to this).
608
608
  * @returns {Point} The converted local position.
609
609
  */
610
- public toLocal(position: Point, from: DisplayObject) {
610
+ public toLocal(position: Point, from: DisplayObject): Point {
611
611
  if (from) {
612
612
  position = from.toGlobal(position);
613
613
  }
@@ -619,7 +619,7 @@ export class DisplayObject {
619
619
  * Renders a cached sprite for this display object.
620
620
  * @param {object} renderSession - The rendering session.
621
621
  */
622
- public renderCachedSprite(renderSession: RenderSession) {
622
+ public renderCachedSprite(renderSession: RenderSession): void {
623
623
  if (!this._cachedSprite) {
624
624
  return;
625
625
  }
@@ -634,14 +634,14 @@ export class DisplayObject {
634
634
  /**
635
635
  * Generates a cached sprite for this display object.
636
636
  */
637
- public generateCachedSprite() {
637
+ public generateCachedSprite(): void {
638
638
  // TODO
639
639
  }
640
640
 
641
641
  /**
642
642
  * Destroys the cached sprite for this display object.
643
643
  */
644
- public destroyCachedSprite() {
644
+ public destroyCachedSprite(): void {
645
645
  if (!this._cachedSprite) {
646
646
  return;
647
647
  }
@@ -655,7 +655,7 @@ export class DisplayObject {
655
655
  * Gets the width of this display object.
656
656
  * @returns {number} The width in pixels.
657
657
  */
658
- public get width() {
658
+ public get width(): number {
659
659
  return this.getLocalBounds().width * this.scale.x;
660
660
  }
661
661
 
@@ -677,7 +677,7 @@ export class DisplayObject {
677
677
  * Gets the height of this display object.
678
678
  * @returns {number} The height in pixels.
679
679
  */
680
- public get height() {
680
+ public get height(): number {
681
681
  return this.getLocalBounds().height * this.scale.y;
682
682
  }
683
683
 
@@ -699,7 +699,7 @@ export class DisplayObject {
699
699
  * Gets the x position of this display object.
700
700
  * @returns {number} The x position in pixels.
701
701
  */
702
- public get x() {
702
+ public get x(): number {
703
703
  return this.position.x;
704
704
  }
705
705
 
@@ -715,7 +715,7 @@ export class DisplayObject {
715
715
  * Gets the y position of this display object.
716
716
  * @returns {number} The y position in pixels.
717
717
  */
718
- public get y() {
718
+ public get y(): number {
719
719
  return this.position.y;
720
720
  }
721
721
 
@@ -731,7 +731,7 @@ export class DisplayObject {
731
731
  * Gets whether this display object is visible in the world.
732
732
  * @returns {boolean} True if the object is visible, false otherwise.
733
733
  */
734
- public get worldVisible() {
734
+ public get worldVisible(): boolean {
735
735
  if (!this.visible) {
736
736
  return false;
737
737
  }
@@ -754,7 +754,7 @@ export class DisplayObject {
754
754
  * Gets the mask for this display object.
755
755
  * @returns {Graphics} The mask object or null if none is set.
756
756
  */
757
- public get mask() {
757
+ public get mask(): Graphics | null {
758
758
  return this._mask;
759
759
  }
760
760
 
@@ -778,7 +778,7 @@ export class DisplayObject {
778
778
  * Gets the x offset for this display object (based on anchor point).
779
779
  * @returns {number} The x offset in pixels.
780
780
  */
781
- public get offsetX() {
781
+ public get offsetX(): number {
782
782
  return this.anchor.x * this.width;
783
783
  }
784
784
 
@@ -786,7 +786,7 @@ export class DisplayObject {
786
786
  * Gets the y offset for this display object (based on anchor point).
787
787
  * @returns {number} The y offset in pixels.
788
788
  */
789
- public get offsetY() {
789
+ public get offsetY(): number {
790
790
  return this.anchor.y * this.height;
791
791
  }
792
792
 
@@ -794,7 +794,7 @@ export class DisplayObject {
794
794
  * Gets the center x position of this display object.
795
795
  * @returns {number} The center x position in pixels.
796
796
  */
797
- public get centerX() {
797
+ public get centerX(): number {
798
798
  return this.x - this.offsetX + this.width * 0.5;
799
799
  }
800
800
 
@@ -810,7 +810,7 @@ export class DisplayObject {
810
810
  * Gets the center y position of this display object.
811
811
  * @returns {number} The center y position in pixels.
812
812
  */
813
- public get centerY() {
813
+ public get centerY(): number {
814
814
  return this.y - this.offsetY + this.height * 0.5;
815
815
  }
816
816
 
@@ -826,7 +826,7 @@ export class DisplayObject {
826
826
  * Gets the left x position of this display object.
827
827
  * @returns {number} The left x position in pixels.
828
828
  */
829
- public get left() {
829
+ public get left(): number {
830
830
  return this.x - this.offsetX;
831
831
  }
832
832
 
@@ -842,7 +842,7 @@ export class DisplayObject {
842
842
  * Gets the right x position of this display object.
843
843
  * @returns {number} The right x position in pixels.
844
844
  */
845
- public get right() {
845
+ public get right(): number {
846
846
  return this.x + this.width - this.offsetX;
847
847
  }
848
848
 
@@ -858,7 +858,7 @@ export class DisplayObject {
858
858
  * Gets the top y position of this display object.
859
859
  * @returns {number} The top y position in pixels.
860
860
  */
861
- public get top() {
861
+ public get top(): number {
862
862
  return this.y - this.offsetY;
863
863
  }
864
864
 
@@ -874,7 +874,7 @@ export class DisplayObject {
874
874
  * Gets the bottom y position of this display object.
875
875
  * @returns {number} The bottom y position in pixels.
876
876
  */
877
- public get bottom() {
877
+ public get bottom(): number {
878
878
  return this.y + this.height - this.offsetY;
879
879
  }
880
880
 
@@ -109,7 +109,7 @@ export class Graphics extends DisplayObject {
109
109
  /**
110
110
  * Destroys the graphics object and clears all data.
111
111
  */
112
- public override destroy() {
112
+ public override destroy(): void {
113
113
  // TODO
114
114
  this.clear();
115
115
  super.destroy();
@@ -122,7 +122,7 @@ export class Graphics extends DisplayObject {
122
122
  * @param {number} alpha - The alpha (transparency) of the line to draw.
123
123
  * @returns {Graphics} This Graphics object for chaining.
124
124
  */
125
- public lineStyle(lineWidth = 0, color = 0, alpha = 1) {
125
+ public lineStyle(lineWidth = 0, color = 0, alpha = 1): this {
126
126
  this.lineWidth = lineWidth || 0;
127
127
  this.lineColor = color || 0;
128
128
  this.lineAlpha = alpha ?? 1;
@@ -146,7 +146,7 @@ export class Graphics extends DisplayObject {
146
146
  * @param {number} y - The y coordinate to move to.
147
147
  * @returns {Graphics} This Graphics object for chaining.
148
148
  */
149
- public moveTo(x: number, y: number) {
149
+ public moveTo(x: number, y: number): this {
150
150
  this.drawShape(new Polygon([x, y]));
151
151
  return this;
152
152
  }
@@ -157,7 +157,7 @@ export class Graphics extends DisplayObject {
157
157
  * @param {number} y - The y coordinate to draw to.
158
158
  * @returns {Graphics} This Graphics object for chaining.
159
159
  */
160
- public lineTo(x: number, y: number) {
160
+ public lineTo(x: number, y: number): this {
161
161
  if (!this.currentPath) {
162
162
  this.moveTo(0, 0);
163
163
  }
@@ -175,7 +175,7 @@ export class Graphics extends DisplayObject {
175
175
  * @param {number} toY - The y coordinate to draw to.
176
176
  * @returns {Graphics} This Graphics object for chaining.
177
177
  */
178
- public quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number) {
178
+ public quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): this {
179
179
  if (this.currentPath) {
180
180
  if (this.currentPath.shape.points.length === 0) {
181
181
  this.currentPath.shape.points = [0, 0];
@@ -214,7 +214,7 @@ export class Graphics extends DisplayObject {
214
214
  * @param {number} toY - The y coordinate to draw to.
215
215
  * @returns {Graphics} This Graphics object for chaining.
216
216
  */
217
- public bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number) {
217
+ public bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): this {
218
218
  if (this.currentPath) {
219
219
  if (this.currentPath.shape.points.length === 0) {
220
220
  this.currentPath.shape.points = [0, 0];
@@ -258,7 +258,7 @@ export class Graphics extends DisplayObject {
258
258
  * @param {number} radius - The radius of the arc.
259
259
  * @returns {Graphics} This Graphics object for chaining.
260
260
  */
261
- public arcTo(x1: number, y1: number, x2: number, y2: number, radius: number) {
261
+ public arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this {
262
262
  if (this.currentPath) {
263
263
  if (this.currentPath.shape.points.length === 0) {
264
264
  this.currentPath.shape.points.push(x1, y1);
@@ -320,7 +320,7 @@ export class Graphics extends DisplayObject {
320
320
  endAngle: number,
321
321
  anticlockwise = false,
322
322
  segments = 40
323
- ) {
323
+ ): this {
324
324
  // If we do this we can never draw a full circle
325
325
  if (startAngle === endAngle) {
326
326
  return this;
@@ -369,7 +369,7 @@ export class Graphics extends DisplayObject {
369
369
  * @param {number} alpha - The fill alpha (transparency) to use.
370
370
  * @returns {Graphics} This Graphics object for chaining.
371
371
  */
372
- public beginFill(color = 0, alpha = 1) {
372
+ public beginFill(color = 0, alpha = 1): this {
373
373
  this.filling = true;
374
374
  this.fillColor = color || 0;
375
375
  this.fillAlpha = alpha ?? 1;
@@ -387,7 +387,7 @@ export class Graphics extends DisplayObject {
387
387
  * Ends the current fill operation.
388
388
  * @returns {Graphics} This Graphics object for chaining.
389
389
  */
390
- public endFill() {
390
+ public endFill(): this {
391
391
  this.filling = false;
392
392
  this.fillColor = null;
393
393
  this.fillAlpha = 1;
@@ -402,7 +402,7 @@ export class Graphics extends DisplayObject {
402
402
  * @param {number} height - The height of the rectangle.
403
403
  * @returns {Graphics} This Graphics object for chaining.
404
404
  */
405
- public drawRect(x: number, y: number, width: number, height: number) {
405
+ public drawRect(x: number, y: number, width: number, height: number): this {
406
406
  this.drawShape(new Rectangle(x, y, width, height));
407
407
  return this;
408
408
  }
@@ -416,7 +416,7 @@ export class Graphics extends DisplayObject {
416
416
  * @param {number} radius - The radius of the rounded corners.
417
417
  * @returns {Graphics} This Graphics object for chaining.
418
418
  */
419
- public drawRoundedRect(x: number, y: number, width: number, height: number, radius: number) {
419
+ public drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): this {
420
420
  this.drawShape(new RoundedRectangle(x, y, width, height, radius));
421
421
  return this;
422
422
  }
@@ -428,7 +428,7 @@ export class Graphics extends DisplayObject {
428
428
  * @param {number} diameter - The diameter of the circle.
429
429
  * @returns {Graphics} This Graphics object for chaining.
430
430
  */
431
- public drawCircle(x: number, y: number, diameter: number) {
431
+ public drawCircle(x: number, y: number, diameter: number): this {
432
432
  this.drawShape(new Circle(x, y, diameter));
433
433
  return this;
434
434
  }
@@ -441,7 +441,7 @@ export class Graphics extends DisplayObject {
441
441
  * @param {number} height - The height of the ellipse.
442
442
  * @returns {Graphics} This Graphics object for chaining.
443
443
  */
444
- public drawEllipse(x: number, y: number, width: number, height: number) {
444
+ public drawEllipse(x: number, y: number, width: number, height: number): this {
445
445
  this.drawShape(new Ellipse(x, y, width, height));
446
446
  return this;
447
447
  }
@@ -451,7 +451,7 @@ export class Graphics extends DisplayObject {
451
451
  * @param {Polygon} path - The polygon to draw.
452
452
  * @returns {Graphics} This Graphics object for chaining.
453
453
  */
454
- public drawPolygon(path: Polygon) {
454
+ public drawPolygon(path: Polygon): this {
455
455
  let points;
456
456
  if (path instanceof Polygon) {
457
457
  points = path.points;
@@ -475,7 +475,7 @@ export class Graphics extends DisplayObject {
475
475
  * Clears all graphics data.
476
476
  * @returns {Graphics} This Graphics object for chaining.
477
477
  */
478
- public clear() {
478
+ public clear(): this {
479
479
  this.lineWidth = 0;
480
480
  this.filling = false;
481
481
  this.dirty = true;
@@ -489,7 +489,7 @@ export class Graphics extends DisplayObject {
489
489
  /**
490
490
  * Generates a texture from the graphics object (not implemented).
491
491
  */
492
- public override generateTexture() {
492
+ public override generateTexture(): void {
493
493
  // TODO
494
494
  this.game.logger.warn('graphics.generateTexture() is not implemented');
495
495
  }
@@ -498,7 +498,7 @@ export class Graphics extends DisplayObject {
498
498
  * Renders the graphics object using WebGL.
499
499
  * @param {object} renderSession - The render session to use.
500
500
  */
501
- public override renderWebGL(renderSession: RenderSession) {
501
+ public override renderWebGL(renderSession: RenderSession): void {
502
502
  // if the sprite is not visible or the alpha is 0 then no need to render this element
503
503
  if (!this.visible || this.alpha === 0 || this.isMask) {
504
504
  return;
@@ -558,7 +558,7 @@ export class Graphics extends DisplayObject {
558
558
  * Renders the graphics object using Canvas.
559
559
  * @param {object} renderSession - The render session to use.
560
560
  */
561
- public override renderCanvas(renderSession: RenderSession) {
561
+ public override renderCanvas(renderSession: RenderSession): void {
562
562
  // if the sprite is not visible or the alpha is 0 then no need to render this element
563
563
  if (!this.visible || this.alpha === 0 || this.isMask) {
564
564
  return;
@@ -616,7 +616,7 @@ export class Graphics extends DisplayObject {
616
616
  * @param {Matrix} matrix - The transformation matrix to use.
617
617
  * @returns {Rectangle} The bounds rectangle of the graphics object.
618
618
  */
619
- public override getBounds(matrix: Matrix | null = null) {
619
+ public override getBounds(matrix: Matrix | null = null): Rectangle {
620
620
  if (!this.renderable) {
621
621
  return getEmptyRectangle();
622
622
  }
@@ -676,7 +676,7 @@ export class Graphics extends DisplayObject {
676
676
  * Gets the local bounds of the graphics object.
677
677
  * @returns {Rectangle} The local bounds rectangle of the graphics object.
678
678
  */
679
- public override getLocalBounds() {
679
+ public override getLocalBounds(): Rectangle {
680
680
  const matrixCache = this.worldTransform;
681
681
  this.worldTransform = getIdentityMatrix();
682
682
  for (const child of this.children) {
@@ -696,7 +696,7 @@ export class Graphics extends DisplayObject {
696
696
  * @param {Point} tempPoint - A temporary point object to use.
697
697
  * @returns {boolean} True if the graphics object contains the point, otherwise false.
698
698
  */
699
- public containsPoint(point: Point, tempPoint: Point) {
699
+ public containsPoint(point: Point, tempPoint: Point): boolean {
700
700
  this.worldTransform.applyInverse(point, tempPoint);
701
701
  const { graphicsData } = this;
702
702
  for (const data of graphicsData) {
@@ -712,7 +712,7 @@ export class Graphics extends DisplayObject {
712
712
  /**
713
713
  * Updates the local bounds of the graphics object.
714
714
  */
715
- public updateLocalBounds() {
715
+ public updateLocalBounds(): void {
716
716
  let minX = Infinity;
717
717
  let maxX = -Infinity;
718
718
  let minY = Infinity;
@@ -791,7 +791,7 @@ export class Graphics extends DisplayObject {
791
791
  /**
792
792
  * Generates a cached sprite representation of the graphics object.
793
793
  */
794
- public override generateCachedSprite() {
794
+ public override generateCachedSprite(): void {
795
795
  const bounds = this.getLocalBounds();
796
796
  if (!this._cachedSprite) {
797
797
  const canvasBuffer = new CanvasBuffer(bounds.width, bounds.height);
@@ -817,7 +817,7 @@ export class Graphics extends DisplayObject {
817
817
  /**
818
818
  * Updates the cached sprite texture.
819
819
  */
820
- public updateCachedSpriteTexture() {
820
+ public updateCachedSpriteTexture(): void {
821
821
  const cachedSprite = this._cachedSprite!;
822
822
  const { texture } = cachedSprite;
823
823
  const { canvas } = cachedSprite.buffer;
@@ -836,7 +836,7 @@ export class Graphics extends DisplayObject {
836
836
  /**
837
837
  * Destroys the cached sprite.
838
838
  */
839
- public override destroyCachedSprite() {
839
+ public override destroyCachedSprite(): void {
840
840
  if (!this._cachedSprite) {
841
841
  return;
842
842
  }
@@ -849,7 +849,7 @@ export class Graphics extends DisplayObject {
849
849
  * @param {object} shape - The shape to draw.
850
850
  * @returns {GraphicsData} The graphics data for the drawn shape.
851
851
  */
852
- public drawShape(shape: GraphicsShape) {
852
+ public drawShape(shape: GraphicsShape): GraphicsData {
853
853
  if (this.currentPath) {
854
854
  // check current path!
855
855
  if (this.currentPath.shape.points.length <= 2) {
@@ -885,7 +885,7 @@ export class Graphics extends DisplayObject {
885
885
  /**
886
886
  * Performs post-update operations for the graphics object.
887
887
  */
888
- public override postUpdate() {
888
+ public override postUpdate(): void {
889
889
  if (this._boundsDirty) {
890
890
  this.updateLocalBounds();
891
891
  this._boundsDirty = false;
@@ -900,7 +900,7 @@ export class Graphics extends DisplayObject {
900
900
  * @param {Point[]} points - The points of the triangle.
901
901
  * @param {boolean} cull - Whether to perform backface culling.
902
902
  */
903
- public drawTriangle(points: Point[], cull = false) {
903
+ public drawTriangle(points: Point[], cull = false): void {
904
904
  const triangle = new Polygon(points);
905
905
  if (cull) {
906
906
  const [a, b, c] = points as [Point, Point, Point];
@@ -922,7 +922,7 @@ export class Graphics extends DisplayObject {
922
922
  * @param {number[]} indices - The indices of the vertices to use.
923
923
  * @param {boolean} cull - Whether to perform backface culling.
924
924
  */
925
- public drawTriangles(vertices: any, indices: number[], cull = false) {
925
+ public drawTriangles(vertices: any, indices: number[], cull = false): void {
926
926
  const point1 = new Point();
927
927
  const point2 = new Point();
928
928
  const point3 = new Point();
@@ -56,7 +56,7 @@ export class GraphicsData {
56
56
  * Clones this GraphicsData object.
57
57
  * @returns {GraphicsData} A new cloned GraphicsData object.
58
58
  */
59
- public clone() {
59
+ public clone(): GraphicsData {
60
60
  return clone(this);
61
61
  }
62
62
  }
@@ -5,7 +5,7 @@ import { GraphicsData } from './graphics_data.js';
5
5
  * @param {GraphicsData} source - The source GraphicsData to clone.
6
6
  * @returns {GraphicsData} A new cloned GraphicsData object.
7
7
  */
8
- export const clone = (source: GraphicsData) =>
8
+ export const clone = (source: GraphicsData): GraphicsData =>
9
9
  new GraphicsData(
10
10
  source.lineWidth,
11
11
  source.lineColor,