@vpmedia/phaser 1.11.0 → 1.13.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 (306) hide show
  1. package/README.md +1 -1
  2. package/package.json +8 -5
  3. package/src/index.js +19 -19
  4. package/src/phaser/core/animation.js +12 -9
  5. package/src/phaser/core/animation_manager.js +16 -6
  6. package/src/phaser/core/animation_parser.js +40 -17
  7. package/src/phaser/core/array_set.js +3 -5
  8. package/src/phaser/core/cache.js +12 -12
  9. package/src/phaser/core/const.js +1 -1
  10. package/src/phaser/core/device.js +2 -4
  11. package/src/phaser/core/device_util.js +50 -17
  12. package/src/phaser/core/dom.js +36 -27
  13. package/src/phaser/core/event_manager.js +47 -19
  14. package/src/phaser/core/factory.js +34 -12
  15. package/src/phaser/core/frame.js +3 -5
  16. package/src/phaser/core/frame_data.js +2 -4
  17. package/src/phaser/core/frame_util.js +11 -9
  18. package/src/phaser/core/game.js +22 -19
  19. package/src/phaser/core/input.js +24 -16
  20. package/src/phaser/core/input_handler.js +102 -28
  21. package/src/phaser/core/input_mouse.js +12 -16
  22. package/src/phaser/core/input_mspointer.js +11 -10
  23. package/src/phaser/core/input_pointer.js +61 -20
  24. package/src/phaser/core/input_touch.js +7 -9
  25. package/src/phaser/core/loader.js +171 -54
  26. package/src/phaser/core/loader_parser.js +29 -22
  27. package/src/phaser/core/raf.js +2 -4
  28. package/src/phaser/core/scale_manager.js +75 -31
  29. package/src/phaser/core/scene.js +2 -4
  30. package/src/phaser/core/scene_manager.js +9 -6
  31. package/src/phaser/core/signal.js +19 -11
  32. package/src/phaser/core/signal_binding.js +12 -7
  33. package/src/phaser/core/sound.js +23 -14
  34. package/src/phaser/core/sound_manager.js +62 -26
  35. package/src/phaser/core/sound_sprite.js +34 -34
  36. package/src/phaser/core/stage.js +4 -7
  37. package/src/phaser/core/time.js +3 -5
  38. package/src/phaser/core/timer.js +27 -10
  39. package/src/phaser/core/timer_event.js +1 -3
  40. package/src/phaser/core/tween.js +36 -12
  41. package/src/phaser/core/tween_data.js +17 -9
  42. package/src/phaser/core/tween_easing.js +87 -83
  43. package/src/phaser/core/tween_manager.js +34 -16
  44. package/src/phaser/core/world.js +3 -5
  45. package/src/phaser/display/bitmap_text.js +25 -14
  46. package/src/phaser/display/button.js +35 -8
  47. package/src/phaser/display/canvas/buffer.js +1 -3
  48. package/src/phaser/display/canvas/graphics.js +30 -15
  49. package/src/phaser/display/canvas/masker.js +7 -5
  50. package/src/phaser/display/canvas/pool.js +18 -11
  51. package/src/phaser/display/canvas/renderer.js +40 -20
  52. package/src/phaser/display/canvas/tinter.js +61 -19
  53. package/src/phaser/display/canvas/util.js +44 -35
  54. package/src/phaser/display/display_object.js +42 -24
  55. package/src/phaser/display/graphics.js +72 -39
  56. package/src/phaser/display/graphics_data.js +3 -4
  57. package/src/phaser/display/graphics_data_util.js +15 -5
  58. package/src/phaser/display/group.js +15 -9
  59. package/src/phaser/display/image.js +17 -9
  60. package/src/phaser/display/sprite_batch.js +8 -4
  61. package/src/phaser/display/sprite_util.js +67 -26
  62. package/src/phaser/display/text.js +92 -31
  63. package/src/phaser/display/webgl/abstract_filter.js +1 -3
  64. package/src/phaser/display/webgl/base_texture.js +8 -5
  65. package/src/phaser/display/webgl/blend_manager.js +1 -3
  66. package/src/phaser/display/webgl/earcut.js +170 -129
  67. package/src/phaser/display/webgl/earcut_node.js +1 -3
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
  69. package/src/phaser/display/webgl/filter_manager.js +1 -3
  70. package/src/phaser/display/webgl/filter_texture.js +17 -6
  71. package/src/phaser/display/webgl/graphics.js +72 -50
  72. package/src/phaser/display/webgl/graphics_data.js +2 -4
  73. package/src/phaser/display/webgl/mask_manager.js +17 -7
  74. package/src/phaser/display/webgl/render_texture.js +19 -10
  75. package/src/phaser/display/webgl/renderer.js +41 -9
  76. package/src/phaser/display/webgl/shader/complex.js +1 -3
  77. package/src/phaser/display/webgl/shader/fast.js +9 -4
  78. package/src/phaser/display/webgl/shader/normal.js +43 -15
  79. package/src/phaser/display/webgl/shader/primitive.js +1 -3
  80. package/src/phaser/display/webgl/shader/strip.js +1 -3
  81. package/src/phaser/display/webgl/shader_manager.js +1 -3
  82. package/src/phaser/display/webgl/sprite_batch.js +14 -15
  83. package/src/phaser/display/webgl/stencil_manager.js +19 -21
  84. package/src/phaser/display/webgl/texture.js +14 -10
  85. package/src/phaser/display/webgl/texture_util.js +11 -9
  86. package/src/phaser/display/webgl/util.js +21 -18
  87. package/src/phaser/geom/circle.js +27 -11
  88. package/src/phaser/geom/ellipse.js +26 -10
  89. package/src/phaser/geom/line.js +31 -13
  90. package/src/phaser/geom/matrix.js +14 -5
  91. package/src/phaser/geom/point.js +18 -13
  92. package/src/phaser/geom/polygon.js +13 -8
  93. package/src/phaser/geom/rectangle.js +57 -14
  94. package/src/phaser/geom/rounded_rectangle.js +12 -4
  95. package/src/phaser/geom/util/circle.js +40 -32
  96. package/src/phaser/geom/util/ellipse.js +10 -18
  97. package/src/phaser/geom/util/line.js +46 -37
  98. package/src/phaser/geom/util/matrix.js +11 -9
  99. package/src/phaser/geom/util/point.js +101 -79
  100. package/src/phaser/geom/util/polygon.js +7 -15
  101. package/src/phaser/geom/util/rectangle.js +95 -69
  102. package/src/phaser/geom/util/rounded_rectangle.js +7 -15
  103. package/src/phaser/util/math.js +123 -89
  104. package/types/global.d.ts +7 -0
  105. package/types/index.d.ts +22 -0
  106. package/types/index.d.ts.map +1 -0
  107. package/types/phaser/core/animation.d.ts +55 -0
  108. package/types/phaser/core/animation.d.ts.map +1 -0
  109. package/types/phaser/core/animation_manager.d.ts +35 -0
  110. package/types/phaser/core/animation_manager.d.ts.map +1 -0
  111. package/types/phaser/core/animation_parser.d.ts +22 -0
  112. package/types/phaser/core/animation_parser.d.ts.map +1 -0
  113. package/types/phaser/core/array_set.d.ts +23 -0
  114. package/types/phaser/core/array_set.d.ts.map +1 -0
  115. package/types/phaser/core/cache.d.ts +106 -0
  116. package/types/phaser/core/cache.d.ts.map +1 -0
  117. package/types/phaser/core/const.d.ts +81 -0
  118. package/types/phaser/core/const.d.ts.map +1 -0
  119. package/types/phaser/core/device.d.ts +36 -0
  120. package/types/phaser/core/device.d.ts.map +1 -0
  121. package/types/phaser/core/device_util.d.ts +58 -0
  122. package/types/phaser/core/device_util.d.ts.map +1 -0
  123. package/types/phaser/core/dom.d.ts +63 -0
  124. package/types/phaser/core/dom.d.ts.map +1 -0
  125. package/types/phaser/core/event_manager.d.ts +53 -0
  126. package/types/phaser/core/event_manager.d.ts.map +1 -0
  127. package/types/phaser/core/factory.d.ts +12 -0
  128. package/types/phaser/core/factory.d.ts.map +1 -0
  129. package/types/phaser/core/frame.d.ts +30 -0
  130. package/types/phaser/core/frame.d.ts.map +1 -0
  131. package/types/phaser/core/frame_data.d.ts +14 -0
  132. package/types/phaser/core/frame_data.d.ts.map +1 -0
  133. package/types/phaser/core/frame_util.d.ts +17 -0
  134. package/types/phaser/core/frame_util.d.ts.map +1 -0
  135. package/types/phaser/core/game.d.ts +57 -0
  136. package/types/phaser/core/game.d.ts.map +1 -0
  137. package/types/phaser/core/input.d.ts +92 -0
  138. package/types/phaser/core/input.d.ts.map +1 -0
  139. package/types/phaser/core/input_handler.d.ts +111 -0
  140. package/types/phaser/core/input_handler.d.ts.map +1 -0
  141. package/types/phaser/core/input_mouse.d.ts +39 -0
  142. package/types/phaser/core/input_mouse.d.ts.map +1 -0
  143. package/types/phaser/core/input_mspointer.d.ts +34 -0
  144. package/types/phaser/core/input_mspointer.d.ts.map +1 -0
  145. package/types/phaser/core/input_pointer.d.ts +68 -0
  146. package/types/phaser/core/input_pointer.d.ts.map +1 -0
  147. package/types/phaser/core/input_touch.d.ts +37 -0
  148. package/types/phaser/core/input_touch.d.ts.map +1 -0
  149. package/types/phaser/core/loader.d.ts +94 -0
  150. package/types/phaser/core/loader.d.ts.map +1 -0
  151. package/types/phaser/core/loader_parser.d.ts +39 -0
  152. package/types/phaser/core/loader_parser.d.ts.map +1 -0
  153. package/types/phaser/core/raf.d.ts +15 -0
  154. package/types/phaser/core/raf.d.ts.map +1 -0
  155. package/types/phaser/core/scale_manager.d.ts +137 -0
  156. package/types/phaser/core/scale_manager.d.ts.map +1 -0
  157. package/types/phaser/core/scene.d.ts +17 -0
  158. package/types/phaser/core/scene.d.ts.map +1 -0
  159. package/types/phaser/core/scene_manager.d.ts +39 -0
  160. package/types/phaser/core/scene_manager.d.ts.map +1 -0
  161. package/types/phaser/core/signal.d.ts +25 -0
  162. package/types/phaser/core/signal.d.ts.map +1 -0
  163. package/types/phaser/core/signal_binding.d.ts +26 -0
  164. package/types/phaser/core/signal_binding.d.ts.map +1 -0
  165. package/types/phaser/core/sound.d.ts +72 -0
  166. package/types/phaser/core/sound.d.ts.map +1 -0
  167. package/types/phaser/core/sound_manager.d.ts +50 -0
  168. package/types/phaser/core/sound_manager.d.ts.map +1 -0
  169. package/types/phaser/core/sound_sprite.d.ts +18 -0
  170. package/types/phaser/core/sound_sprite.d.ts.map +1 -0
  171. package/types/phaser/core/stage.d.ts +23 -0
  172. package/types/phaser/core/stage.d.ts.map +1 -0
  173. package/types/phaser/core/time.d.ts +49 -0
  174. package/types/phaser/core/time.d.ts.map +1 -0
  175. package/types/phaser/core/timer.d.ts +49 -0
  176. package/types/phaser/core/timer.d.ts.map +1 -0
  177. package/types/phaser/core/timer_event.d.ts +18 -0
  178. package/types/phaser/core/timer_event.d.ts.map +1 -0
  179. package/types/phaser/core/tween.d.ts +52 -0
  180. package/types/phaser/core/tween.d.ts.map +1 -0
  181. package/types/phaser/core/tween_data.d.ts +37 -0
  182. package/types/phaser/core/tween_data.d.ts.map +1 -0
  183. package/types/phaser/core/tween_easing.d.ts +192 -0
  184. package/types/phaser/core/tween_easing.d.ts.map +1 -0
  185. package/types/phaser/core/tween_manager.d.ts +94 -0
  186. package/types/phaser/core/tween_manager.d.ts.map +1 -0
  187. package/types/phaser/core/world.d.ts +6 -0
  188. package/types/phaser/core/world.d.ts.map +1 -0
  189. package/types/phaser/display/bitmap_text.d.ts +59 -0
  190. package/types/phaser/display/bitmap_text.d.ts.map +1 -0
  191. package/types/phaser/display/button.d.ts +47 -0
  192. package/types/phaser/display/button.d.ts.map +1 -0
  193. package/types/phaser/display/canvas/buffer.d.ts +11 -0
  194. package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
  195. package/types/phaser/display/canvas/graphics.d.ts +21 -0
  196. package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
  197. package/types/phaser/display/canvas/masker.d.ts +14 -0
  198. package/types/phaser/display/canvas/masker.d.ts.map +1 -0
  199. package/types/phaser/display/canvas/pool.d.ts +52 -0
  200. package/types/phaser/display/canvas/pool.d.ts.map +1 -0
  201. package/types/phaser/display/canvas/renderer.d.ts +28 -0
  202. package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
  203. package/types/phaser/display/canvas/tinter.d.ts +41 -0
  204. package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
  205. package/types/phaser/display/canvas/util.d.ts +79 -0
  206. package/types/phaser/display/canvas/util.d.ts.map +1 -0
  207. package/types/phaser/display/display_object.d.ts +83 -0
  208. package/types/phaser/display/display_object.d.ts.map +1 -0
  209. package/types/phaser/display/graphics.d.ts +60 -0
  210. package/types/phaser/display/graphics.d.ts.map +1 -0
  211. package/types/phaser/display/graphics_data.d.ts +15 -0
  212. package/types/phaser/display/graphics_data.d.ts.map +1 -0
  213. package/types/phaser/display/graphics_data_util.d.ts +8 -0
  214. package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
  215. package/types/phaser/display/group.d.ts +49 -0
  216. package/types/phaser/display/group.d.ts.map +1 -0
  217. package/types/phaser/display/image.d.ts +52 -0
  218. package/types/phaser/display/image.d.ts.map +1 -0
  219. package/types/phaser/display/sprite_batch.d.ts +11 -0
  220. package/types/phaser/display/sprite_batch.d.ts.map +1 -0
  221. package/types/phaser/display/sprite_util.d.ts +40 -0
  222. package/types/phaser/display/sprite_util.d.ts.map +1 -0
  223. package/types/phaser/display/text.d.ts +125 -0
  224. package/types/phaser/display/text.d.ts.map +1 -0
  225. package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
  226. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
  227. package/types/phaser/display/webgl/base_texture.d.ts +20 -0
  228. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
  229. package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
  230. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
  231. package/types/phaser/display/webgl/earcut.d.ts +215 -0
  232. package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
  233. package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
  234. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
  235. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
  236. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
  237. package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
  238. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
  239. package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
  240. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
  241. package/types/phaser/display/webgl/graphics.d.ts +80 -0
  242. package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
  243. package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
  244. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
  245. package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
  246. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
  247. package/types/phaser/display/webgl/render_texture.d.ts +25 -0
  248. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
  249. package/types/phaser/display/webgl/renderer.d.ts +44 -0
  250. package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
  251. package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
  252. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
  253. package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
  254. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
  255. package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
  256. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
  257. package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
  258. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
  259. package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
  260. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
  261. package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
  262. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
  263. package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
  264. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
  265. package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
  266. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
  267. package/types/phaser/display/webgl/texture.d.ts +30 -0
  268. package/types/phaser/display/webgl/texture.d.ts.map +1 -0
  269. package/types/phaser/display/webgl/texture_util.d.ts +17 -0
  270. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
  271. package/types/phaser/display/webgl/util.d.ts +45 -0
  272. package/types/phaser/display/webgl/util.d.ts.map +1 -0
  273. package/types/phaser/geom/circle.d.ts +46 -0
  274. package/types/phaser/geom/circle.d.ts.map +1 -0
  275. package/types/phaser/geom/ellipse.d.ts +26 -0
  276. package/types/phaser/geom/ellipse.d.ts.map +1 -0
  277. package/types/phaser/geom/line.d.ts +45 -0
  278. package/types/phaser/geom/line.d.ts.map +1 -0
  279. package/types/phaser/geom/matrix.d.ts +35 -0
  280. package/types/phaser/geom/matrix.d.ts.map +1 -0
  281. package/types/phaser/geom/point.d.ts +43 -0
  282. package/types/phaser/geom/point.d.ts.map +1 -0
  283. package/types/phaser/geom/polygon.d.ts +17 -0
  284. package/types/phaser/geom/polygon.d.ts.map +1 -0
  285. package/types/phaser/geom/rectangle.d.ts +71 -0
  286. package/types/phaser/geom/rectangle.d.ts.map +1 -0
  287. package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
  288. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
  289. package/types/phaser/geom/util/circle.d.ts +64 -0
  290. package/types/phaser/geom/util/circle.d.ts.map +1 -0
  291. package/types/phaser/geom/util/ellipse.d.ts +16 -0
  292. package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
  293. package/types/phaser/geom/util/line.d.ts +49 -0
  294. package/types/phaser/geom/util/line.d.ts.map +1 -0
  295. package/types/phaser/geom/util/matrix.d.ts +22 -0
  296. package/types/phaser/geom/util/matrix.d.ts.map +1 -0
  297. package/types/phaser/geom/util/point.d.ts +179 -0
  298. package/types/phaser/geom/util/point.d.ts.map +1 -0
  299. package/types/phaser/geom/util/polygon.d.ts +10 -0
  300. package/types/phaser/geom/util/polygon.d.ts.map +1 -0
  301. package/types/phaser/geom/util/rectangle.d.ts +141 -0
  302. package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
  303. package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
  304. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
  305. package/types/phaser/util/math.d.ts +182 -0
  306. package/types/phaser/util/math.d.ts.map +1 -0
@@ -1,17 +1,20 @@
1
1
  /**
2
+ * @module display/display_object
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import Point from '../geom/point';
7
- import Rectangle from '../geom/rectangle';
8
- import Matrix from '../geom/matrix';
7
+ import { Point } from '../geom/point';
8
+ import { Rectangle } from '../geom/rectangle';
9
+ import { Matrix } from '../geom/matrix';
9
10
  import { getIdentityMatrix } from '../geom/util/matrix';
10
11
  import { PI_2 } from '../util/math';
11
12
  import { renderCanvas, renderWebGL } from './sprite_util';
12
13
 
13
- export default class {
14
-
14
+ export class DisplayObject {
15
+ /**
16
+ * TBD.
17
+ */
15
18
  constructor() {
16
19
  this.exists = true;
17
20
  this.renderable = false;
@@ -83,7 +86,13 @@ export default class {
83
86
  this.children.splice(index, 0, child);
84
87
  return child;
85
88
  }
86
- throw new Error(child + 'addChildAt: The index ' + index + ' supplied is out of bounds ' + this.children.length);
89
+ throw new Error(
90
+ child +
91
+ 'addChildAt: The index ' +
92
+ index +
93
+ ' supplied is out of bounds ' +
94
+ this.children.length
95
+ );
87
96
  }
88
97
 
89
98
  swapChildren(child, child2) {
@@ -93,7 +102,9 @@ export default class {
93
102
  const index1 = this.getChildIndex(child);
94
103
  const index2 = this.getChildIndex(child2);
95
104
  if (index1 < 0 || index2 < 0) {
96
- throw new Error('swapChildren: Both the supplied DisplayObjects must be a child of the caller.');
105
+ throw new Error(
106
+ 'swapChildren: Both the supplied DisplayObjects must be a child of the caller.'
107
+ );
97
108
  }
98
109
  this.children[index1] = child2;
99
110
  this.children[index2] = child;
@@ -118,7 +129,11 @@ export default class {
118
129
 
119
130
  getChildAt(index) {
120
131
  if (index < 0 || index >= this.children.length) {
121
- throw new Error('getChildAt: Supplied index ' + index + ' does not exist in the child list, or the supplied DisplayObject must be a child of the caller');
132
+ throw new Error(
133
+ 'getChildAt: Supplied index ' +
134
+ index +
135
+ ' does not exist in the child list, or the supplied DisplayObject must be a child of the caller'
136
+ );
122
137
  }
123
138
  return this.children[index];
124
139
  }
@@ -228,7 +243,10 @@ export default class {
228
243
  // Set the World values
229
244
  this.worldAlpha = this.alpha * p.worldAlpha;
230
245
  // this.worldPosition.set(wt.tx, wt.ty);
231
- this.worldScale.set(this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c), this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d));
246
+ this.worldScale.set(
247
+ this.scale.x * Math.sqrt(wt.a * wt.a + wt.c * wt.c),
248
+ this.scale.y * Math.sqrt(wt.b * wt.b + wt.d * wt.d)
249
+ );
232
250
  this.worldRotation = Math.atan2(-wt.c, wt.d);
233
251
  // reset the bounds each time this is called!
234
252
  this.currentBounds = null;
@@ -243,7 +261,8 @@ export default class {
243
261
  }
244
262
 
245
263
  getBounds(targetCoordinateSpace) {
246
- const isTargetCoordinateSpaceDisplayObject = (targetCoordinateSpace && targetCoordinateSpace.contains !== undefined);
264
+ const isTargetCoordinateSpaceDisplayObject =
265
+ targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
247
266
  let isTargetCoordinateSpaceThisOrParent = true;
248
267
  if (!isTargetCoordinateSpaceDisplayObject) {
249
268
  targetCoordinateSpace = this;
@@ -274,12 +293,12 @@ export default class {
274
293
  if (child.visible) {
275
294
  childVisible = true;
276
295
  childBounds = this.children[i].getBounds();
277
- minX = (minX < childBounds.x) ? minX : childBounds.x;
278
- minY = (minY < childBounds.y) ? minY : childBounds.y;
296
+ minX = minX < childBounds.x ? minX : childBounds.x;
297
+ minY = minY < childBounds.y ? minY : childBounds.y;
279
298
  childMaxX = childBounds.width + childBounds.x;
280
299
  childMaxY = childBounds.height + childBounds.y;
281
- maxX = (maxX > childMaxX) ? maxX : childMaxX;
282
- maxY = (maxY > childMaxY) ? maxY : childMaxY;
300
+ maxX = maxX > childMaxX ? maxX : childMaxX;
301
+ maxY = maxY > childMaxY ? maxY : childMaxY;
283
302
  }
284
303
  }
285
304
  let bounds = this.cachedBounds;
@@ -542,19 +561,19 @@ export default class {
542
561
  }
543
562
 
544
563
  get centerX() {
545
- return (this.x - this.offsetX) + (this.width * 0.5);
564
+ return this.x - this.offsetX + this.width * 0.5;
546
565
  }
547
566
 
548
567
  set centerX(value) {
549
- this.x = (value + this.offsetX) - (this.width * 0.5);
568
+ this.x = value + this.offsetX - this.width * 0.5;
550
569
  }
551
570
 
552
571
  get centerY() {
553
- return (this.y - this.offsetY) + (this.height * 0.5);
572
+ return this.y - this.offsetY + this.height * 0.5;
554
573
  }
555
574
 
556
575
  set centerY(value) {
557
- this.y = (value + this.offsetY) - (this.height * 0.5);
576
+ this.y = value + this.offsetY - this.height * 0.5;
558
577
  }
559
578
 
560
579
  get left() {
@@ -566,11 +585,11 @@ export default class {
566
585
  }
567
586
 
568
587
  get right() {
569
- return (this.x + this.width) - this.offsetX;
588
+ return this.x + this.width - this.offsetX;
570
589
  }
571
590
 
572
591
  set right(value) {
573
- this.x = value - (this.width) + this.offsetX;
592
+ this.x = value - this.width + this.offsetX;
574
593
  }
575
594
 
576
595
  get top() {
@@ -582,11 +601,10 @@ export default class {
582
601
  }
583
602
 
584
603
  get bottom() {
585
- return (this.y + this.height) - this.offsetY;
604
+ return this.y + this.height - this.offsetY;
586
605
  }
587
606
 
588
607
  set bottom(value) {
589
- this.y = value - (this.height) + this.offsetY;
608
+ this.y = value - this.height + this.offsetY;
590
609
  }
591
-
592
610
  }
@@ -1,28 +1,46 @@
1
1
  /**
2
+ * @module display/graphics
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import DisplayObject from './display_object';
7
- import Image from './image';
8
- import Rectangle from '../geom/rectangle';
9
- import RoundedRectangle from '../geom/rounded_rectangle';
10
- import Polygon from '../geom/polygon';
11
- import Circle from '../geom/circle';
12
- import Ellipse from '../geom/ellipse';
13
- import Point from '../geom/point';
14
- import GraphicsData from './graphics_data';
7
+ import { DisplayObject } from './display_object';
8
+ import { Image } from './image';
9
+ import { Rectangle } from '../geom/rectangle';
10
+ import { RoundedRectangle } from '../geom/rounded_rectangle';
11
+ import { Polygon } from '../geom/polygon';
12
+ import { Circle } from '../geom/circle';
13
+ import { Ellipse } from '../geom/ellipse';
14
+ import { Point } from '../geom/point';
15
+ import { GraphicsData } from './graphics_data';
15
16
  import CanvasBuffer from './canvas/buffer';
16
17
  import { textureFromCanvas } from './webgl/texture_util';
17
18
  import { renderGraphics as renderCanvasGraphics } from './canvas/graphics';
18
19
  import { renderGraphics as renderWebGLGraphics } from './webgl/graphics';
19
- import { renderCanvas as renderSpriteCanvas, renderWebGL as renderSpriteWebGL } from './sprite_util';
20
+ import {
21
+ renderCanvas as renderSpriteCanvas,
22
+ renderWebGL as renderSpriteWebGL,
23
+ } from './sprite_util';
20
24
  import { getEmptyRectangle } from '../geom/util/rectangle';
21
25
  import { getIdentityMatrix } from '../geom/util/matrix';
22
- import { BLEND_NORMAL, GRAPHICS, GEOM_POLYGON, GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../core/const';
23
-
24
- export default class extends DisplayObject {
25
-
26
+ import {
27
+ BLEND_NORMAL,
28
+ GRAPHICS,
29
+ GEOM_POLYGON,
30
+ GEOM_CIRCLE,
31
+ GEOM_ELLIPSE,
32
+ GEOM_RECTANGLE,
33
+ GEOM_ROUNDED_RECTANGLE,
34
+ } from '../core/const';
35
+
36
+ export class Graphics extends DisplayObject {
37
+ /**
38
+ * TBD.
39
+ *
40
+ * @param {object} game - TBD.
41
+ * @param {number} x - TBD.
42
+ * @param {number} y - TBD.
43
+ */
26
44
  constructor(game, x = 0, y = 0) {
27
45
  super();
28
46
  this.game = game;
@@ -33,7 +51,7 @@ export default class extends DisplayObject {
33
51
  this.lineWidth = 0;
34
52
  this.lineColor = 0;
35
53
  this.graphicsData = [];
36
- this.tint = 0xFFFFFF;
54
+ this.tint = 0xffffff;
37
55
  this.blendMode = BLEND_NORMAL;
38
56
  this.currentPath = null;
39
57
  this._webGL = [];
@@ -55,7 +73,7 @@ export default class extends DisplayObject {
55
73
  lineStyle(lineWidth = 0, color = 0, alpha = 1) {
56
74
  this.lineWidth = lineWidth || 0;
57
75
  this.lineColor = color || 0;
58
- this.lineAlpha = (alpha === undefined) ? 1 : alpha;
76
+ this.lineAlpha = alpha === undefined ? 1 : alpha;
59
77
  if (this.currentPath) {
60
78
  if (this.currentPath.shape.points.length) {
61
79
  // halfway through a line? start a new one!
@@ -105,9 +123,9 @@ export default class extends DisplayObject {
105
123
  let j = 0;
106
124
  for (let i = 1; i <= n; i += 1) {
107
125
  j = i / n;
108
- xa = fromX + ((cpX - fromX) * j);
109
- ya = fromY + ((cpY - fromY) * j);
110
- points.push(xa + (((cpX + ((toX - cpX) * j)) - xa) * j), ya + (((cpY + ((toY - cpY) * j)) - ya) * j));
126
+ xa = fromX + (cpX - fromX) * j;
127
+ ya = fromY + (cpY - fromY) * j;
128
+ points.push(xa + (cpX + (toX - cpX) * j - xa) * j, ya + (cpY + (toY - cpY) * j - ya) * j);
111
129
  }
112
130
  this.dirty = true;
113
131
  this._boundsDirty = true;
@@ -134,12 +152,15 @@ export default class extends DisplayObject {
134
152
  let j = 0;
135
153
  for (let i = 1; i <= n; i += 1) {
136
154
  j = i / n;
137
- dt = (1 - j);
155
+ dt = 1 - j;
138
156
  dt2 = dt * dt;
139
157
  dt3 = dt2 * dt;
140
158
  t2 = j * j;
141
159
  t3 = t2 * j;
142
- points.push(dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX, dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY);
160
+ points.push(
161
+ dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX,
162
+ dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY
163
+ );
143
164
  }
144
165
  this.dirty = true;
145
166
  this._boundsDirty = true;
@@ -170,10 +191,10 @@ export default class extends DisplayObject {
170
191
  const dd = a1 * a1 + b1 * b1;
171
192
  const cc = a2 * a2 + b2 * b2;
172
193
  const tt = a1 * a2 + b1 * b2;
173
- const k1 = radius * Math.sqrt(dd) / mm;
174
- const k2 = radius * Math.sqrt(cc) / mm;
175
- const j1 = k1 * tt / dd;
176
- const j2 = k2 * tt / cc;
194
+ const k1 = (radius * Math.sqrt(dd)) / mm;
195
+ const k2 = (radius * Math.sqrt(cc)) / mm;
196
+ const j1 = (k1 * tt) / dd;
197
+ const j2 = (k2 * tt) / cc;
177
198
  const cx = k1 * b2 + k2 * b1;
178
199
  const cy = k1 * a2 + k2 * a1;
179
200
  const px = b1 * (k2 + j1);
@@ -199,7 +220,7 @@ export default class extends DisplayObject {
199
220
  } else if (anticlockwise && startAngle <= endAngle) {
200
221
  startAngle += Math.PI * 2;
201
222
  }
202
- const sweep = anticlockwise ? (startAngle - endAngle) * -1 : (endAngle - startAngle);
223
+ const sweep = anticlockwise ? (startAngle - endAngle) * -1 : endAngle - startAngle;
203
224
  const segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * segments;
204
225
  // Sweep check - moved here because we don't want to do the moveTo below if the arc fails
205
226
  if (sweep === 0) {
@@ -222,10 +243,13 @@ export default class extends DisplayObject {
222
243
  const remainder = (segMinus % 1) / segMinus;
223
244
  for (let i = 0; i <= segMinus; i += 1) {
224
245
  const real = i + remainder * i;
225
- const angle = ((theta) + startAngle + (theta2 * real));
246
+ const angle = theta + startAngle + theta2 * real;
226
247
  const c = Math.cos(angle);
227
248
  const s = -Math.sin(angle);
228
- points.push(((cTheta * c) + (sTheta * s)) * radius + cx, ((cTheta * -s) + (sTheta * c)) * radius + cy);
249
+ points.push(
250
+ (cTheta * c + sTheta * s) * radius + cx,
251
+ (cTheta * -s + sTheta * c) * radius + cy
252
+ );
229
253
  }
230
254
  this.dirty = true;
231
255
  this._boundsDirty = true;
@@ -235,7 +259,7 @@ export default class extends DisplayObject {
235
259
  beginFill(color = 0, alpha = 1) {
236
260
  this.filling = true;
237
261
  this.fillColor = color || 0;
238
- this.fillAlpha = (alpha === undefined) ? 1 : alpha;
262
+ this.fillAlpha = alpha === undefined ? 1 : alpha;
239
263
  if (this.currentPath) {
240
264
  if (this.currentPath.shape.points.length <= 2) {
241
265
  this.currentPath.fill = this.filling;
@@ -336,7 +360,8 @@ export default class extends DisplayObject {
336
360
  // check blend mode
337
361
  if (this.blendMode !== renderSession.spriteBatch.currentBlendMode) {
338
362
  renderSession.spriteBatch.currentBlendMode = this.blendMode;
339
- const blendModeWebGL = window.PhaserRegistry.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
363
+ const blendModeWebGL =
364
+ window.PhaserRegistry.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
340
365
  renderSession.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
341
366
  }
342
367
  // check if the webgl graphic needs to be updated
@@ -390,21 +415,22 @@ export default class extends DisplayObject {
390
415
  const transform = this.worldTransform;
391
416
  if (this.blendMode !== renderSession.currentBlendMode) {
392
417
  renderSession.currentBlendMode = this.blendMode;
393
- context.globalCompositeOperation = window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
418
+ context.globalCompositeOperation =
419
+ window.PhaserRegistry.blendModesCanvas[renderSession.currentBlendMode];
394
420
  }
395
421
  if (this._mask) {
396
422
  renderSession.maskManager.pushMask(this._mask, renderSession);
397
423
  }
398
424
  const resolution = renderSession.resolution;
399
- const tx = (transform.tx * renderSession.resolution) + renderSession.shakeX;
400
- const ty = (transform.ty * renderSession.resolution) + renderSession.shakeY;
425
+ const tx = transform.tx * renderSession.resolution + renderSession.shakeX;
426
+ const ty = transform.ty * renderSession.resolution + renderSession.shakeY;
401
427
  context.setTransform(
402
428
  transform.a * resolution,
403
429
  transform.b * resolution,
404
430
  transform.c * resolution,
405
431
  transform.d * resolution,
406
432
  tx,
407
- ty,
433
+ ty
408
434
  );
409
435
  renderCanvasGraphics(this, context);
410
436
  // simple render children!
@@ -574,9 +600,9 @@ export default class extends DisplayObject {
574
600
  }
575
601
  const padding = this.boundsPadding;
576
602
  this._localBounds.x = minX - padding;
577
- this._localBounds.width = (maxX - minX) + padding * 2;
603
+ this._localBounds.width = maxX - minX + padding * 2;
578
604
  this._localBounds.y = minY - padding;
579
- this._localBounds.height = (maxY - minY) + padding * 2;
605
+ this._localBounds.height = maxY - minY + padding * 2;
580
606
  }
581
607
 
582
608
  generateCachedSprite() {
@@ -639,7 +665,15 @@ export default class extends DisplayObject {
639
665
  shape = shape.clone();
640
666
  shape.flatten();
641
667
  }
642
- const data = new GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, shape);
668
+ const data = new GraphicsData(
669
+ this.lineWidth,
670
+ this.lineColor,
671
+ this.lineAlpha,
672
+ this.fillColor,
673
+ this.fillAlpha,
674
+ this.filling,
675
+ shape
676
+ );
643
677
  this.graphicsData.push(data);
644
678
  if (data.type === GEOM_POLYGON) {
645
679
  data.shape.closed = this.filling;
@@ -719,5 +753,4 @@ export default class extends DisplayObject {
719
753
  }
720
754
  }
721
755
  }
722
-
723
756
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
+ * @module display/graphics_data
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
7
  import { clone } from './graphics_data_util';
7
8
 
8
- export default class {
9
-
9
+ export class GraphicsData {
10
10
  constructor(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape) {
11
11
  this.lineWidth = lineWidth;
12
12
  this.lineColor = lineColor;
@@ -23,5 +23,4 @@ export default class {
23
23
  clone() {
24
24
  return clone(this);
25
25
  }
26
-
27
26
  }
@@ -1,15 +1,25 @@
1
1
  /**
2
+ * @module display/graphics_data_util
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import GraphicsData from './graphics_data';
7
+ import { GraphicsData } from './graphics_data';
7
8
 
8
9
  /**
10
+ * TBD.
9
11
  *
10
- * @param {object} source TBD
11
- * @returns {object} TBD
12
+ * @param {object} source - TBD.
13
+ * @returns {object} TBD.
12
14
  */
13
15
  export function clone(source) {
14
- return new GraphicsData(source.lineWidth, source.lineColor, source.lineAlpha, source.fillColor, source.fillAlpha, source.fill, source.shape);
16
+ return new GraphicsData(
17
+ source.lineWidth,
18
+ source.lineColor,
19
+ source.lineAlpha,
20
+ source.fillColor,
21
+ source.fillAlpha,
22
+ source.fill,
23
+ source.shape
24
+ );
15
25
  }
@@ -1,18 +1,26 @@
1
1
  /**
2
+ * @module display/group
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import DisplayObject from './display_object';
7
- import Image from './image';
8
- import Signal from '../core/signal';
7
+ import { DisplayObject } from './display_object';
8
+ import { Image } from './image';
9
+ import { Signal } from '../core/signal';
9
10
  import { GROUP } from '../core/const';
10
11
 
11
12
  export const SORT_ASCENDING = -1;
12
13
  export const SORT_DESCENDING = 1;
13
14
 
14
- export default class extends DisplayObject {
15
-
15
+ export class Group extends DisplayObject {
16
+ /**
17
+ * TBD.
18
+ *
19
+ * @param {object} game - TBD.
20
+ * @param {DisplayObject} parent - TBD.
21
+ * @param {string} name - TBD.
22
+ * @param {boolean} addToStage - TBD.
23
+ */
16
24
  constructor(game, parent = null, name = 'group', addToStage = false) {
17
25
  super();
18
26
  this.game = game;
@@ -219,9 +227,7 @@ export default class extends DisplayObject {
219
227
  if (destroy && removed) {
220
228
  removed.destroy(true, destroyTexture);
221
229
  }
222
- }
223
- while (this.children.length > 0);
230
+ } while (this.children.length > 0);
224
231
  this.cursor = null;
225
232
  }
226
-
227
233
  }
@@ -1,19 +1,28 @@
1
1
  /**
2
+ * @module display/image
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import Texture from './webgl/texture';
7
+ import { Texture } from './webgl/texture';
7
8
  import AnimationManager from '../core/animation_manager';
8
9
  import EventManager from '../core/event_manager';
9
- import Rectangle from '../geom/rectangle';
10
- import DisplayObject from './display_object';
10
+ import { Rectangle } from '../geom/rectangle';
11
+ import { DisplayObject } from './display_object';
11
12
  import { clone } from '../geom/util/rectangle';
12
13
  import { IMAGE, PENDING_ATLAS, BLEND_NORMAL, SCALE_NEAREST } from '../core/const';
13
14
  import { setTexture, getBounds, getLocalBounds, renderCanvas, renderWebGL } from './sprite_util';
14
15
 
15
- export default class extends DisplayObject {
16
-
16
+ export class Image extends DisplayObject {
17
+ /**
18
+ * TBD.
19
+ *
20
+ * @param {object} game - TBD.
21
+ * @param {number} x - TBD.
22
+ * @param {number} y - TBD.
23
+ * @param {string} key - TBD.
24
+ * @param {string} frame - TBD.
25
+ */
17
26
  constructor(game, x, y, key, frame) {
18
27
  super();
19
28
  this.game = game;
@@ -24,7 +33,7 @@ export default class extends DisplayObject {
24
33
  this.data = {};
25
34
  this._width = 0;
26
35
  this._height = 0;
27
- this.tint = 0xFFFFFF;
36
+ this.tint = 0xffffff;
28
37
  this.cachedTint = -1;
29
38
  this.tintedTexture = null;
30
39
  this.blendMode = BLEND_NORMAL;
@@ -44,7 +53,7 @@ export default class extends DisplayObject {
44
53
  this.key = null;
45
54
  this.data = null;
46
55
  this.texture = null;
47
- this.tint = 0xFFFFFF;
56
+ this.tint = 0xffffff;
48
57
  this.cachedTint = -1;
49
58
  this.tintedTexture = null;
50
59
  this.shader = null;
@@ -284,5 +293,4 @@ export default class extends DisplayObject {
284
293
  renderCanvas(renderSession, matrix = null) {
285
294
  renderCanvas(this, renderSession, matrix);
286
295
  }
287
-
288
296
  }
@@ -1,15 +1,19 @@
1
1
  /**
2
+ * @module display/sprite_batch
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import DisplayObject from './display_object';
7
+ import { DisplayObject } from './display_object';
7
8
 
8
9
  export default class extends DisplayObject {
9
-
10
+ /**
11
+ * TBD.
12
+ *
13
+ * @param {object} game - TBD.
14
+ */
10
15
  constructor(game) {
11
16
  super();
12
17
  this.game = game;
13
18
  }
14
-
15
19
  }