@vpmedia/phaser 1.14.0 → 1.16.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 +3 -3
  2. package/package.json +6 -5
  3. package/src/index.js +15 -18
  4. package/src/phaser/core/animation.js +102 -6
  5. package/src/phaser/core/animation_manager.js +88 -10
  6. package/src/phaser/core/animation_parser.js +5 -20
  7. package/src/phaser/core/array_set.js +51 -5
  8. package/src/phaser/core/cache.js +291 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +5 -6
  11. package/src/phaser/core/device_util.js +3 -25
  12. package/src/phaser/core/dom.js +127 -29
  13. package/src/phaser/core/event_manager.js +128 -6
  14. package/src/phaser/core/factory.js +69 -34
  15. package/src/phaser/core/frame.js +43 -6
  16. package/src/phaser/core/frame_data.js +55 -5
  17. package/src/phaser/core/frame_util.js +7 -14
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +116 -17
  20. package/src/phaser/core/input_handler.js +242 -42
  21. package/src/phaser/core/input_mouse.js +68 -7
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +79 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +274 -101
  26. package/src/phaser/core/loader_parser.js +2 -14
  27. package/src/phaser/core/raf.js +16 -5
  28. package/src/phaser/core/scale_manager.js +204 -39
  29. package/src/phaser/core/scene.js +24 -5
  30. package/src/phaser/core/scene_manager.js +81 -11
  31. package/src/phaser/core/signal.js +88 -11
  32. package/src/phaser/core/signal_binding.js +35 -15
  33. package/src/phaser/core/sound.js +99 -10
  34. package/src/phaser/core/sound_manager.js +89 -13
  35. package/src/phaser/core/sound_sprite.js +20 -5
  36. package/src/phaser/core/stage.js +43 -7
  37. package/src/phaser/core/time.js +67 -5
  38. package/src/phaser/core/timer.js +107 -30
  39. package/src/phaser/core/timer_event.js +11 -6
  40. package/src/phaser/core/tween.js +124 -30
  41. package/src/phaser/core/tween_data.js +42 -18
  42. package/src/phaser/core/tween_easing.js +1 -39
  43. package/src/phaser/core/tween_manager.js +47 -5
  44. package/src/phaser/core/world.js +9 -6
  45. package/src/phaser/display/bitmap_text.js +92 -11
  46. package/src/phaser/display/button.js +64 -13
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -16
  49. package/src/phaser/display/canvas/masker.js +0 -8
  50. package/src/phaser/display/canvas/pool.js +0 -14
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -48
  53. package/src/phaser/display/canvas/util.js +0 -15
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +162 -27
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -9
  58. package/src/phaser/display/group.js +75 -10
  59. package/src/phaser/display/image.js +86 -10
  60. package/src/phaser/display/sprite_batch.js +3 -9
  61. package/src/phaser/display/sprite_util.js +3 -28
  62. package/src/phaser/display/text.js +332 -32
  63. package/src/phaser/display/webgl/abstract_filter.js +8 -7
  64. package/src/phaser/display/webgl/base_texture.js +20 -12
  65. package/src/phaser/display/webgl/blend_manager.js +14 -7
  66. package/src/phaser/display/webgl/earcut.js +4 -50
  67. package/src/phaser/display/webgl/earcut_node.js +6 -7
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
  69. package/src/phaser/display/webgl/filter_manager.js +25 -7
  70. package/src/phaser/display/webgl/filter_texture.js +21 -22
  71. package/src/phaser/display/webgl/graphics.js +5 -40
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -8
  74. package/src/phaser/display/webgl/render_texture.js +33 -21
  75. package/src/phaser/display/webgl/renderer.js +38 -11
  76. package/src/phaser/display/webgl/shader/complex.js +10 -6
  77. package/src/phaser/display/webgl/shader/fast.js +10 -6
  78. package/src/phaser/display/webgl/shader/normal.js +23 -32
  79. package/src/phaser/display/webgl/shader/primitive.js +10 -6
  80. package/src/phaser/display/webgl/shader/strip.js +10 -6
  81. package/src/phaser/display/webgl/shader_manager.js +18 -6
  82. package/src/phaser/display/webgl/sprite_batch.js +41 -8
  83. package/src/phaser/display/webgl/stencil_manager.js +28 -6
  84. package/src/phaser/display/webgl/texture.js +28 -15
  85. package/src/phaser/display/webgl/texture_util.js +0 -8
  86. package/src/phaser/display/webgl/util.js +0 -11
  87. package/src/phaser/geom/circle.js +123 -19
  88. package/src/phaser/geom/ellipse.js +39 -19
  89. package/src/phaser/geom/line.js +148 -17
  90. package/src/phaser/geom/matrix.js +73 -7
  91. package/src/phaser/geom/point.js +152 -7
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -7
  94. package/src/phaser/geom/rounded_rectangle.js +10 -7
  95. package/src/phaser/geom/util/circle.js +3 -16
  96. package/src/phaser/geom/util/ellipse.js +0 -8
  97. package/src/phaser/geom/util/line.js +5 -19
  98. package/src/phaser/geom/util/matrix.js +1 -10
  99. package/src/phaser/geom/util/point.js +0 -26
  100. package/src/phaser/geom/util/polygon.js +1 -8
  101. package/src/phaser/geom/util/rectangle.js +1 -23
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -8
  103. package/src/phaser/util/math.js +3 -43
  104. package/{types → typedefs}/global.d.ts +1 -1
  105. package/types/index.d.ts +2 -1
  106. package/types/index.d.ts.map +1 -1
  107. package/types/phaser/core/animation.d.ts +106 -5
  108. package/types/phaser/core/animation.d.ts.map +1 -1
  109. package/types/phaser/core/animation_manager.d.ts +88 -1
  110. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  111. package/types/phaser/core/animation_parser.d.ts +5 -6
  112. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  113. package/types/phaser/core/array_set.d.ts +53 -7
  114. package/types/phaser/core/array_set.d.ts.map +1 -1
  115. package/types/phaser/core/cache.d.ts +348 -58
  116. package/types/phaser/core/cache.d.ts.map +1 -1
  117. package/types/phaser/core/const.d.ts +143 -40
  118. package/types/phaser/core/const.d.ts.map +1 -1
  119. package/types/phaser/core/device.d.ts +2 -5
  120. package/types/phaser/core/device.d.ts.map +1 -1
  121. package/types/phaser/core/device_util.d.ts +1 -10
  122. package/types/phaser/core/device_util.d.ts.map +1 -1
  123. package/types/phaser/core/dom.d.ts +122 -3
  124. package/types/phaser/core/dom.d.ts.map +1 -1
  125. package/types/phaser/core/event_manager.d.ts +142 -15
  126. package/types/phaser/core/event_manager.d.ts.map +1 -1
  127. package/types/phaser/core/factory.d.ts +74 -7
  128. package/types/phaser/core/factory.d.ts.map +1 -1
  129. package/types/phaser/core/frame.d.ts +68 -26
  130. package/types/phaser/core/frame.d.ts.map +1 -1
  131. package/types/phaser/core/frame_data.d.ts +61 -9
  132. package/types/phaser/core/frame_data.d.ts.map +1 -1
  133. package/types/phaser/core/frame_util.d.ts +10 -10
  134. package/types/phaser/core/frame_util.d.ts.map +1 -1
  135. package/types/phaser/core/game.d.ts +54 -20
  136. package/types/phaser/core/game.d.ts.map +1 -1
  137. package/types/phaser/core/input.d.ts +132 -21
  138. package/types/phaser/core/input.d.ts.map +1 -1
  139. package/types/phaser/core/input_handler.d.ts +258 -25
  140. package/types/phaser/core/input_handler.d.ts.map +1 -1
  141. package/types/phaser/core/input_mouse.d.ts +59 -12
  142. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  143. package/types/phaser/core/input_mspointer.d.ts +49 -15
  144. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  145. package/types/phaser/core/input_pointer.d.ts +80 -4
  146. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  147. package/types/phaser/core/input_touch.d.ts +52 -15
  148. package/types/phaser/core/input_touch.d.ts.map +1 -1
  149. package/types/phaser/core/loader.d.ts +268 -23
  150. package/types/phaser/core/loader.d.ts.map +1 -1
  151. package/types/phaser/core/loader_parser.d.ts +0 -4
  152. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  153. package/types/phaser/core/raf.d.ts +17 -7
  154. package/types/phaser/core/raf.d.ts.map +1 -1
  155. package/types/phaser/core/scale_manager.d.ts +210 -15
  156. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  157. package/types/phaser/core/scene.d.ts +21 -5
  158. package/types/phaser/core/scene.d.ts.map +1 -1
  159. package/types/phaser/core/scene_manager.d.ts +90 -10
  160. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  161. package/types/phaser/core/signal.d.ts +95 -11
  162. package/types/phaser/core/signal.d.ts.map +1 -1
  163. package/types/phaser/core/signal_binding.d.ts +35 -6
  164. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  165. package/types/phaser/core/sound.d.ts +111 -14
  166. package/types/phaser/core/sound.d.ts.map +1 -1
  167. package/types/phaser/core/sound_manager.d.ts +94 -8
  168. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  169. package/types/phaser/core/sound_sprite.d.ts +22 -8
  170. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  171. package/types/phaser/core/stage.d.ts +32 -3
  172. package/types/phaser/core/stage.d.ts.map +1 -1
  173. package/types/phaser/core/time.d.ts +73 -6
  174. package/types/phaser/core/time.d.ts.map +1 -1
  175. package/types/phaser/core/timer.d.ts +103 -2
  176. package/types/phaser/core/timer.d.ts.map +1 -1
  177. package/types/phaser/core/timer_event.d.ts +11 -5
  178. package/types/phaser/core/timer_event.d.ts.map +1 -1
  179. package/types/phaser/core/tween.d.ts +123 -3
  180. package/types/phaser/core/tween.d.ts.map +1 -1
  181. package/types/phaser/core/tween_data.d.ts +42 -3
  182. package/types/phaser/core/tween_data.d.ts.map +1 -1
  183. package/types/phaser/core/tween_easing.d.ts +0 -36
  184. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  185. package/types/phaser/core/tween_manager.d.ts +49 -2
  186. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  187. package/types/phaser/core/world.d.ts +9 -1
  188. package/types/phaser/core/world.d.ts.map +1 -1
  189. package/types/phaser/display/bitmap_text.d.ts +89 -12
  190. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  191. package/types/phaser/display/button.d.ts +68 -11
  192. package/types/phaser/display/button.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/buffer.d.ts +21 -5
  194. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/graphics.d.ts +0 -3
  196. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/masker.d.ts +0 -2
  198. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/pool.d.ts +0 -13
  200. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  201. package/types/phaser/display/canvas/renderer.d.ts +30 -3
  202. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  203. package/types/phaser/display/canvas/tinter.d.ts +0 -5
  204. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  205. package/types/phaser/display/canvas/util.d.ts +0 -9
  206. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  207. package/types/phaser/display/display_object.d.ts +196 -9
  208. package/types/phaser/display/display_object.d.ts.map +1 -1
  209. package/types/phaser/display/graphics.d.ts +142 -16
  210. package/types/phaser/display/graphics.d.ts.map +1 -1
  211. package/types/phaser/display/graphics_data.d.ts +15 -1
  212. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  213. package/types/phaser/display/graphics_data_util.d.ts +3 -3
  214. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  215. package/types/phaser/display/group.d.ts +68 -6
  216. package/types/phaser/display/group.d.ts.map +1 -1
  217. package/types/phaser/display/image.d.ts +77 -15
  218. package/types/phaser/display/image.d.ts.map +1 -1
  219. package/types/phaser/display/sprite_batch.d.ts +4 -4
  220. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  221. package/types/phaser/display/sprite_util.d.ts +0 -5
  222. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  223. package/types/phaser/display/text.d.ts +373 -53
  224. package/types/phaser/display/text.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  226. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  228. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  230. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/earcut.d.ts +0 -27
  232. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  234. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  235. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  236. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/filter_manager.d.ts +23 -7
  238. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  240. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/graphics.d.ts +0 -12
  242. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/graphics_data.d.ts +12 -8
  244. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/mask_manager.d.ts +0 -2
  246. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/render_texture.d.ts +31 -4
  248. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/renderer.d.ts +42 -5
  250. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader/complex.d.ts +12 -2
  252. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/shader/fast.d.ts +12 -2
  254. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/shader/normal.d.ts +21 -1
  256. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/shader/primitive.d.ts +12 -2
  258. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/shader/strip.d.ts +12 -2
  260. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  261. package/types/phaser/display/webgl/shader_manager.d.ts +20 -5
  262. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  263. package/types/phaser/display/webgl/sprite_batch.d.ts +38 -1
  264. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  265. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  266. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  267. package/types/phaser/display/webgl/texture.d.ts +22 -1
  268. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  269. package/types/phaser/display/webgl/texture_util.d.ts +0 -2
  270. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  271. package/types/phaser/display/webgl/util.d.ts +0 -10
  272. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  273. package/types/phaser/geom/circle.d.ts +130 -10
  274. package/types/phaser/geom/circle.d.ts.map +1 -1
  275. package/types/phaser/geom/ellipse.d.ts +42 -6
  276. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  277. package/types/phaser/geom/line.d.ts +159 -14
  278. package/types/phaser/geom/line.d.ts.map +1 -1
  279. package/types/phaser/geom/matrix.d.ts +84 -12
  280. package/types/phaser/geom/matrix.d.ts.map +1 -1
  281. package/types/phaser/geom/point.d.ts +170 -19
  282. package/types/phaser/geom/point.d.ts.map +1 -1
  283. package/types/phaser/geom/polygon.d.ts +45 -5
  284. package/types/phaser/geom/polygon.d.ts.map +1 -1
  285. package/types/phaser/geom/rectangle.d.ts +253 -21
  286. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  287. package/types/phaser/geom/rounded_rectangle.d.ts +11 -2
  288. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/geom/util/circle.d.ts +3 -10
  290. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  291. package/types/phaser/geom/util/ellipse.d.ts +0 -7
  292. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  293. package/types/phaser/geom/util/line.d.ts +5 -10
  294. package/types/phaser/geom/util/line.d.ts.map +1 -1
  295. package/types/phaser/geom/util/matrix.d.ts +0 -3
  296. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  297. package/types/phaser/geom/util/point.d.ts +0 -20
  298. package/types/phaser/geom/util/point.d.ts.map +1 -1
  299. package/types/phaser/geom/util/polygon.d.ts +0 -1
  300. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  301. package/types/phaser/geom/util/rectangle.d.ts +0 -16
  302. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  303. package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -1
  304. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  305. package/types/phaser/util/math.d.ts +0 -27
  306. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,15 +1,15 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- */
6
- import { Signal } from './signal';
7
- import { Rectangle } from '../geom/rectangle';
1
+ import { Signal } from './signal';
2
+ import { Rectangle } from '../geom/rectangle';
8
3
  import { canPlayAudio } from './device_util';
4
+ import { Game } from './game';
9
5
 
10
6
  const TEXTURE_ATLAS_JSON_HASH = 1;
11
7
 
12
8
  export class Loader {
9
+ /**
10
+ * TBD.
11
+ * @param {Game} game - TBD.
12
+ */
13
13
  constructor(game) {
14
14
  this.game = game;
15
15
  this.cache = game.cache;
@@ -45,6 +45,11 @@ export class Loader {
45
45
  this._loadedFileCount = 0;
46
46
  }
47
47
 
48
+ /**
49
+ * TBD.
50
+ * @param sprite
51
+ * @param direction
52
+ */
48
53
  setPreloadSprite(sprite, direction = 0) {
49
54
  this.preloadSprite = {
50
55
  sprite,
@@ -64,16 +69,29 @@ export class Loader {
64
69
  sprite.visible = true;
65
70
  }
66
71
 
72
+ /**
73
+ * TBD.
74
+ */
67
75
  resize() {
68
76
  if (this.preloadSprite && this.preloadSprite.height !== this.preloadSprite.sprite.height) {
69
77
  this.preloadSprite.rect.height = this.preloadSprite.sprite.height;
70
78
  }
71
79
  }
72
80
 
81
+ /**
82
+ * TBD.
83
+ * @param type
84
+ * @param {string} key - TBD.
85
+ */
73
86
  checkKeyExists(type, key) {
74
87
  return this.getAssetIndex(type, key) > -1;
75
88
  }
76
89
 
90
+ /**
91
+ * TBD.
92
+ * @param type
93
+ * @param {string} key - TBD.
94
+ */
77
95
  getAssetIndex(type, key) {
78
96
  let bestFound = -1;
79
97
  for (let i = 0; i < this._fileList.length; i += 1) {
@@ -90,6 +108,11 @@ export class Loader {
90
108
  return bestFound;
91
109
  }
92
110
 
111
+ /**
112
+ * TBD.
113
+ * @param type
114
+ * @param {string} key - TBD.
115
+ */
93
116
  getAsset(type, key) {
94
117
  const fileIndex = this.getAssetIndex(type, key);
95
118
  if (fileIndex > -1) {
@@ -98,6 +121,11 @@ export class Loader {
98
121
  return null;
99
122
  }
100
123
 
124
+ /**
125
+ * TBD.
126
+ * @param hard
127
+ * @param clearEvents
128
+ */
101
129
  reset(hard, clearEvents = false) {
102
130
  if (hard) {
103
131
  this.preloadSprite = null;
@@ -121,14 +149,16 @@ export class Loader {
121
149
  }
122
150
  }
123
151
 
124
- addToFileList(
125
- type,
126
- key = '',
127
- url = null,
128
- properties = null,
129
- overwrite = false,
130
- extension = null
131
- ) {
152
+ /**
153
+ * TBD.
154
+ * @param type
155
+ * @param {string} key - TBD.
156
+ * @param url
157
+ * @param properties
158
+ * @param overwrite
159
+ * @param extension
160
+ */
161
+ addToFileList(type, key = '', url = null, properties = null, overwrite = false, extension = null) {
132
162
  if (key === undefined || key === '') {
133
163
  console.warn('Loader: Invalid or no key given of type ' + type);
134
164
  return this;
@@ -175,10 +205,24 @@ export class Loader {
175
205
  return this;
176
206
  }
177
207
 
208
+ /**
209
+ * TBD.
210
+ * @param type
211
+ * @param {string} key - TBD.
212
+ * @param url
213
+ * @param properties
214
+ */
178
215
  replaceInFileList(type, key, url, properties) {
179
216
  return this.addToFileList(type, key, url, properties, true);
180
217
  }
181
218
 
219
+ /**
220
+ * TBD.
221
+ * @param {string} key - TBD.
222
+ * @param url
223
+ * @param data
224
+ * @param callbackContext
225
+ */
182
226
  pack(key, url, data, callbackContext) {
183
227
  const pack = {
184
228
  type: 'packfile',
@@ -210,10 +254,21 @@ export class Loader {
210
254
  return this;
211
255
  }
212
256
 
257
+ /**
258
+ * TBD.
259
+ * @param {string} key - TBD.
260
+ * @param url
261
+ * @param overwrite
262
+ */
213
263
  image(key, url, overwrite) {
214
264
  return this.addToFileList('image', key, url, undefined, overwrite, '.png');
215
265
  }
216
266
 
267
+ /**
268
+ * TBD.
269
+ * @param keys
270
+ * @param urls
271
+ */
217
272
  images(keys, urls) {
218
273
  if (Array.isArray(urls)) {
219
274
  for (let i = 0; i < keys.length; i += 1) {
@@ -227,18 +282,46 @@ export class Loader {
227
282
  return this;
228
283
  }
229
284
 
285
+ /**
286
+ * TBD.
287
+ * @param {string} key - TBD.
288
+ * @param url
289
+ * @param overwrite
290
+ */
230
291
  text(key, url, overwrite) {
231
292
  return this.addToFileList('text', key, url, undefined, overwrite, '.txt');
232
293
  }
233
294
 
295
+ /**
296
+ * TBD.
297
+ * @param {string} key - TBD.
298
+ * @param url
299
+ * @param overwrite
300
+ */
234
301
  json(key, url, overwrite) {
235
302
  return this.addToFileList('json', key, url, undefined, overwrite, '.json');
236
303
  }
237
304
 
305
+ /**
306
+ * TBD.
307
+ * @param {string} key - TBD.
308
+ * @param url
309
+ * @param overwrite
310
+ */
238
311
  xml(key, url, overwrite) {
239
312
  return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
240
313
  }
241
314
 
315
+ /**
316
+ * TBD.
317
+ * @param {string} key - TBD.
318
+ * @param url
319
+ * @param frameWidth
320
+ * @param frameHeight
321
+ * @param frameMax
322
+ * @param margin
323
+ * @param spacing
324
+ */
242
325
  spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
243
326
  return this.addToFileList(
244
327
  'spritesheet',
@@ -250,6 +333,12 @@ export class Loader {
250
333
  );
251
334
  }
252
335
 
336
+ /**
337
+ * TBD.
338
+ * @param {string} key - TBD.
339
+ * @param urls
340
+ * @param autoDecode
341
+ */
253
342
  audio(key, urls, autoDecode = true) {
254
343
  if (this.game.sound.noAudio) {
255
344
  return this;
@@ -260,6 +349,14 @@ export class Loader {
260
349
  return this.addToFileList('audio', key, urls, { buffer: null, autoDecode });
261
350
  }
262
351
 
352
+ /**
353
+ * TBD.
354
+ * @param {string} key - TBD.
355
+ * @param urls
356
+ * @param jsonURL
357
+ * @param jsonData
358
+ * @param autoDecode
359
+ */
263
360
  audioSprite(key, urls, jsonURL, jsonData, autoDecode = true) {
264
361
  if (this.game.sound.noAudio) {
265
362
  return this;
@@ -276,14 +373,16 @@ export class Loader {
276
373
  return this;
277
374
  }
278
375
 
279
- bitmapFont(
280
- key,
281
- textureURL = null,
282
- atlasURL = null,
283
- atlasData = null,
284
- xSpacing = 0,
285
- ySpacing = 0
286
- ) {
376
+ /**
377
+ * TBD.
378
+ * @param {string} key - TBD.
379
+ * @param textureURL
380
+ * @param atlasURL
381
+ * @param atlasData
382
+ * @param xSpacing
383
+ * @param ySpacing
384
+ */
385
+ bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
287
386
  if (textureURL === undefined || textureURL === null) {
288
387
  textureURL = key + '.png';
289
388
  }
@@ -316,6 +415,14 @@ export class Loader {
316
415
  return this;
317
416
  }
318
417
 
418
+ /**
419
+ * TBD.
420
+ * @param {string} key - TBD.
421
+ * @param textureURL
422
+ * @param atlasURL
423
+ * @param atlasData
424
+ * @param format
425
+ */
319
426
  atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
320
427
  if (textureURL === undefined || textureURL === null) {
321
428
  textureURL = key + '.png';
@@ -332,6 +439,11 @@ export class Loader {
332
439
  return this;
333
440
  }
334
441
 
442
+ /**
443
+ * TBD.
444
+ * @param callback - TBD.
445
+ * @param callbackContext
446
+ */
335
447
  withSyncPoint(callback, callbackContext) {
336
448
  this._withSyncPointDepth += 1;
337
449
  try {
@@ -342,6 +454,11 @@ export class Loader {
342
454
  return this;
343
455
  }
344
456
 
457
+ /**
458
+ * TBD.
459
+ * @param type
460
+ * @param {string} key - TBD.
461
+ */
345
462
  addSyncPoint(type, key) {
346
463
  const asset = this.getAsset(type, key);
347
464
  if (asset) {
@@ -350,6 +467,11 @@ export class Loader {
350
467
  return this;
351
468
  }
352
469
 
470
+ /**
471
+ * TBD.
472
+ * @param type
473
+ * @param {string} key - TBD.
474
+ */
353
475
  removeFile(type, key) {
354
476
  const asset = this.getAsset(type, key);
355
477
  if (asset) {
@@ -359,11 +481,17 @@ export class Loader {
359
481
  }
360
482
  }
361
483
 
484
+ /**
485
+ * TBD.
486
+ */
362
487
  removeAll() {
363
488
  this._fileList.length = 0;
364
489
  this._flightQueue.length = 0;
365
490
  }
366
491
 
492
+ /**
493
+ * TBD.
494
+ */
367
495
  start() {
368
496
  if (this.isLoading) {
369
497
  return;
@@ -374,6 +502,9 @@ export class Loader {
374
502
  this.processLoadQueue();
375
503
  }
376
504
 
505
+ /**
506
+ * TBD.
507
+ */
377
508
  processLoadQueue() {
378
509
  if (!this.isLoading) {
379
510
  console.warn('Loader - active loading canceled / reset');
@@ -404,12 +535,7 @@ export class Loader {
404
535
  } else if (file.type === 'packfile' && file.error) {
405
536
  // Non-error pack files are handled when processing the file queue
406
537
  this._loadedPackCount += 1;
407
- this.onPackComplete.dispatch(
408
- file.key,
409
- !file.error,
410
- this._loadedPackCount,
411
- this._totalPackCount
412
- );
538
+ this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
413
539
  }
414
540
  }
415
541
  }
@@ -423,12 +549,7 @@ export class Loader {
423
549
  // Processing the pack / adds more files
424
550
  this.processPack(file);
425
551
  this._loadedPackCount += 1;
426
- this.onPackComplete.dispatch(
427
- file.key,
428
- !file.error,
429
- this._loadedPackCount,
430
- this._totalPackCount
431
- );
552
+ this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
432
553
  }
433
554
  if (file.loaded || file.error) {
434
555
  // Item at the start of file list finished, can skip it in future
@@ -459,10 +580,7 @@ export class Loader {
459
580
  }
460
581
  // Stop looking if queue full - or if syncblocked and there are no more packs.
461
582
  // (As only packs can be loaded around a syncblock)
462
- if (
463
- this._flightQueue.length >= inflightLimit ||
464
- (syncblock && this._loadedPackCount === this._totalPackCount)
465
- ) {
583
+ if (this._flightQueue.length >= inflightLimit || (syncblock && this._loadedPackCount === this._totalPackCount)) {
466
584
  break;
467
585
  }
468
586
  }
@@ -482,6 +600,10 @@ export class Loader {
482
600
  }
483
601
  }
484
602
 
603
+ /**
604
+ * TBD.
605
+ * @param abnormal
606
+ */
485
607
  finishedLoading(abnormal) {
486
608
  if (this.hasLoaded) {
487
609
  return;
@@ -501,6 +623,11 @@ export class Loader {
501
623
  // this.reset();
502
624
  }
503
625
 
626
+ /**
627
+ * TBD.
628
+ * @param file
629
+ * @param errorMessage
630
+ */
504
631
  asyncComplete(file, errorMessage = '') {
505
632
  file.loaded = true;
506
633
  file.error = !!errorMessage;
@@ -512,6 +639,10 @@ export class Loader {
512
639
  this.processLoadQueue();
513
640
  }
514
641
 
642
+ /**
643
+ * TBD.
644
+ * @param pack
645
+ */
515
646
  processPack(pack) {
516
647
  const packData = pack.data[pack.key];
517
648
  if (!packData) {
@@ -565,18 +696,17 @@ export class Loader {
565
696
  );
566
697
  break;
567
698
  case 'atlas':
568
- this.atlas(
569
- file.key,
570
- file.textureURL,
571
- file.atlasURL,
572
- file.atlasData,
573
- TEXTURE_ATLAS_JSON_HASH
574
- );
699
+ this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
575
700
  break;
576
701
  }
577
702
  }
578
703
  }
579
704
 
705
+ /**
706
+ * TBD.
707
+ * @param url
708
+ * @param file
709
+ */
580
710
  transformUrl(url, file) {
581
711
  if (!url) {
582
712
  return false;
@@ -587,6 +717,10 @@ export class Loader {
587
717
  return this.baseURL + file.path + url;
588
718
  }
589
719
 
720
+ /**
721
+ * TBD.
722
+ * @param file
723
+ */
590
724
  loadFile(file) {
591
725
  switch (file.type) {
592
726
  case 'packfile':
@@ -603,11 +737,7 @@ export class Loader {
603
737
  if (file.url) {
604
738
  this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
605
739
  } else {
606
- this.fileError(
607
- file,
608
- null,
609
- 'No supported audio URL specified or device does not have audio playback support'
610
- );
740
+ this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
611
741
  }
612
742
  break;
613
743
  case 'json':
@@ -625,6 +755,10 @@ export class Loader {
625
755
  }
626
756
  }
627
757
 
758
+ /**
759
+ * TBD.
760
+ * @param file
761
+ */
628
762
  loadImageTag(file) {
629
763
  this.log('loadImageTag', file);
630
764
  const scope = this;
@@ -653,6 +787,14 @@ export class Loader {
653
787
  file.data.src = this.transformUrl(file.url, file);
654
788
  }
655
789
 
790
+ /**
791
+ * TBD.
792
+ * @param file
793
+ * @param url
794
+ * @param type
795
+ * @param onload
796
+ * @param onerror
797
+ */
656
798
  xhrLoad(file, url, type, onload, onerror) {
657
799
  this.log('xhrLoad', file);
658
800
  const scope = this;
@@ -712,11 +854,18 @@ export class Loader {
712
854
  xhr.send();
713
855
  }
714
856
 
857
+ /**
858
+ * TBD.
859
+ */
715
860
  xhrLoadWithXDR() {
716
861
  // TODO
717
862
  console.warn('loader.xhrLoadWithXDR() is not implemented');
718
863
  }
719
864
 
865
+ /**
866
+ * TBD.
867
+ * @param urls
868
+ */
720
869
  getAudioURL(urls) {
721
870
  if (this.game.sound.noAudio) {
722
871
  return null;
@@ -750,6 +899,12 @@ export class Loader {
750
899
  return null;
751
900
  }
752
901
 
902
+ /**
903
+ * TBD.
904
+ * @param file
905
+ * @param xhr
906
+ * @param reason
907
+ */
753
908
  fileError(file, xhr, reason) {
754
909
  // const url = file.requestUrl || this.transformUrl(file.url, file);
755
910
  let message = 'Error loading asset';
@@ -762,6 +917,11 @@ export class Loader {
762
917
  this.asyncComplete(file, message);
763
918
  }
764
919
 
920
+ /**
921
+ * TBD.
922
+ * @param file
923
+ * @param xhr
924
+ */
765
925
  fileComplete(file, xhr) {
766
926
  let loadNext = true;
767
927
  switch (file.type) {
@@ -790,12 +950,7 @@ export class Loader {
790
950
  } else {
791
951
  loadNext = false;
792
952
  if (file.format === TEXTURE_ATLAS_JSON_HASH) {
793
- this.xhrLoad(
794
- file,
795
- this.transformUrl(file.atlasURL, file),
796
- 'text',
797
- this.jsonLoadComplete
798
- );
953
+ this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
799
954
  } else {
800
955
  throw new Error('Invalid Texture Atlas format: ' + file.format);
801
956
  }
@@ -815,27 +970,22 @@ export class Loader {
815
970
  } else {
816
971
  // Load the XML before carrying on with the next file
817
972
  loadNext = false;
818
- this.xhrLoad(
819
- file,
820
- this.transformUrl(file.atlasURL, file),
821
- 'text',
822
- (bitmapFontFile, bitmapFontXhr) => {
823
- let json;
824
- try {
825
- // Try to parse as JSON, if it fails, then it's hopefully XML
826
- json = JSON.parse(bitmapFontXhr.responseText);
827
- } catch (e) {
828
- // pass
829
- }
830
- if (json) {
831
- bitmapFontFile.atlasType = 'json';
832
- this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
833
- } else {
834
- bitmapFontFile.atlasType = 'xml';
835
- this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
836
- }
973
+ this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', (bitmapFontFile, bitmapFontXhr) => {
974
+ let json;
975
+ try {
976
+ // Try to parse as JSON, if it fails, then it's hopefully XML
977
+ json = JSON.parse(bitmapFontXhr.responseText);
978
+ } catch (e) {
979
+ // pass
837
980
  }
838
- );
981
+ if (json) {
982
+ bitmapFontFile.atlasType = 'json';
983
+ this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
984
+ } else {
985
+ bitmapFontFile.atlasType = 'xml';
986
+ this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
987
+ }
988
+ });
839
989
  }
840
990
  break;
841
991
  case 'audio':
@@ -858,18 +1008,15 @@ export class Loader {
858
1008
  }
859
1009
  }
860
1010
 
1011
+ /**
1012
+ * TBD.
1013
+ * @param file
1014
+ * @param xhr
1015
+ */
861
1016
  jsonLoadComplete(file, xhr) {
862
1017
  const data = JSON.parse(xhr.responseText);
863
1018
  if (file.type === 'bitmapfont') {
864
- this.cache.addBitmapFont(
865
- file.key,
866
- file.url,
867
- file.data,
868
- data,
869
- file.atlasType,
870
- file.xSpacing,
871
- file.ySpacing
872
- );
1019
+ this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
873
1020
  } else if (file.type === 'json') {
874
1021
  this.cache.addJSON(file.key, file.url, data);
875
1022
  } else {
@@ -878,11 +1025,19 @@ export class Loader {
878
1025
  this.asyncComplete(file);
879
1026
  }
880
1027
 
1028
+ /**
1029
+ * TBD.
1030
+ */
881
1031
  csvLoadComplete() {
882
1032
  // TODO
883
1033
  console.warn('loader.csvLoadComplete() is not implemented');
884
1034
  }
885
1035
 
1036
+ /**
1037
+ * TBD.
1038
+ * @param file
1039
+ * @param xhr
1040
+ */
886
1041
  xmlLoadComplete(file, xhr) {
887
1042
  // Always try parsing the content as XML, regardless of actually response type
888
1043
  const data = xhr.responseText;
@@ -894,15 +1049,7 @@ export class Loader {
894
1049
  return;
895
1050
  }
896
1051
  if (file.type === 'bitmapfont') {
897
- this.cache.addBitmapFont(
898
- file.key,
899
- file.url,
900
- file.data,
901
- xml,
902
- file.atlasType,
903
- file.xSpacing,
904
- file.ySpacing
905
- );
1052
+ this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
906
1053
  } else if (file.type === 'textureatlas') {
907
1054
  this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
908
1055
  } else if (file.type === 'xml') {
@@ -911,6 +1058,10 @@ export class Loader {
911
1058
  this.asyncComplete(file);
912
1059
  }
913
1060
 
1061
+ /**
1062
+ * TBD.
1063
+ * @param data
1064
+ */
914
1065
  parseXml(data) {
915
1066
  let xml = null;
916
1067
  try {
@@ -932,16 +1083,15 @@ export class Loader {
932
1083
  return xml;
933
1084
  }
934
1085
 
1086
+ /**
1087
+ * TBD.
1088
+ */
935
1089
  updateProgress() {
936
1090
  if (this.preloadSprite) {
937
1091
  if (this.preloadSprite.direction === 0) {
938
- this.preloadSprite.rect.width = Math.floor(
939
- (this.preloadSprite.width / 100) * this.progress
940
- );
1092
+ this.preloadSprite.rect.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
941
1093
  } else {
942
- this.preloadSprite.rect.height = Math.floor(
943
- (this.preloadSprite.height / 100) * this.progress
944
- );
1094
+ this.preloadSprite.rect.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
945
1095
  }
946
1096
  if (this.preloadSprite.sprite) {
947
1097
  this.preloadSprite.sprite.updateCrop();
@@ -952,6 +1102,11 @@ export class Loader {
952
1102
  }
953
1103
  }
954
1104
 
1105
+ /**
1106
+ * TBD.
1107
+ * @param message
1108
+ * @param data
1109
+ */
955
1110
  log(message, data = '') {
956
1111
  if (!this.isUseLog) {
957
1112
  return;
@@ -959,27 +1114,45 @@ export class Loader {
959
1114
  console.log(`[Loader] ${message}`, data);
960
1115
  }
961
1116
 
1117
+ /**
1118
+ * TBD.
1119
+ */
962
1120
  totalLoadedFiles() {
963
1121
  return this._loadedFileCount;
964
1122
  }
965
1123
 
1124
+ /**
1125
+ * TBD.
1126
+ */
966
1127
  totalQueuedFiles() {
967
1128
  return this._totalFileCount - this._loadedFileCount;
968
1129
  }
969
1130
 
1131
+ /**
1132
+ * TBD.
1133
+ */
970
1134
  totalLoadedPacks() {
971
1135
  return this._totalPackCount;
972
1136
  }
973
1137
 
1138
+ /**
1139
+ * TBD.
1140
+ */
974
1141
  totalQueuedPacks() {
975
1142
  return this._totalPackCount - this._loadedPackCount;
976
1143
  }
977
1144
 
1145
+ /**
1146
+ * TBD.
1147
+ */
978
1148
  get progressFloat() {
979
1149
  const progress = (this._loadedFileCount / this._totalFileCount) * 100;
980
1150
  return Math.max(0, Math.min(100, progress || 0));
981
1151
  }
982
1152
 
1153
+ /**
1154
+ * TBD.
1155
+ */
983
1156
  get progress() {
984
1157
  return Math.round(this.progressFloat);
985
1158
  }