@vpmedia/phaser 1.15.0 → 1.17.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 (290) 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 +114 -6
  5. package/src/phaser/core/animation_manager.js +102 -10
  6. package/src/phaser/core/animation_parser.js +6 -19
  7. package/src/phaser/core/array_set.js +59 -5
  8. package/src/phaser/core/cache.js +307 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +3 -6
  11. package/src/phaser/core/device_util.js +3 -16
  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 -12
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +133 -17
  20. package/src/phaser/core/input_handler.js +243 -43
  21. package/src/phaser/core/input_mouse.js +70 -5
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +88 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +303 -101
  26. package/src/phaser/core/loader_parser.js +2 -10
  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 -8
  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 +91 -10
  46. package/src/phaser/display/button.js +63 -12
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -13
  49. package/src/phaser/display/canvas/masker.js +0 -6
  50. package/src/phaser/display/canvas/pool.js +0 -7
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -43
  53. package/src/phaser/display/canvas/util.js +0 -6
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +161 -26
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -8
  58. package/src/phaser/display/group.js +82 -9
  59. package/src/phaser/display/image.js +87 -9
  60. package/src/phaser/display/sprite_batch.js +3 -8
  61. package/src/phaser/display/sprite_util.js +3 -23
  62. package/src/phaser/display/text.js +331 -31
  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 -23
  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 -28
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -6
  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 -6
  86. package/src/phaser/display/webgl/util.js +0 -7
  87. package/src/phaser/geom/circle.js +123 -18
  88. package/src/phaser/geom/ellipse.js +39 -18
  89. package/src/phaser/geom/line.js +148 -16
  90. package/src/phaser/geom/matrix.js +73 -6
  91. package/src/phaser/geom/point.js +152 -6
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -6
  94. package/src/phaser/geom/rounded_rectangle.js +10 -6
  95. package/src/phaser/geom/util/circle.js +3 -9
  96. package/src/phaser/geom/util/ellipse.js +0 -7
  97. package/src/phaser/geom/util/line.js +5 -14
  98. package/src/phaser/geom/util/matrix.js +1 -7
  99. package/src/phaser/geom/util/point.js +0 -6
  100. package/src/phaser/geom/util/polygon.js +1 -7
  101. package/src/phaser/geom/util/rectangle.js +1 -7
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -7
  103. package/src/phaser/util/math.js +3 -21
  104. package/types/index.d.ts +2 -1
  105. package/types/index.d.ts.map +1 -1
  106. package/types/phaser/core/animation.d.ts +126 -13
  107. package/types/phaser/core/animation.d.ts.map +1 -1
  108. package/types/phaser/core/animation_manager.d.ts +121 -19
  109. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  110. package/types/phaser/core/animation_parser.d.ts +6 -5
  111. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  112. package/types/phaser/core/array_set.d.ts +67 -13
  113. package/types/phaser/core/array_set.d.ts.map +1 -1
  114. package/types/phaser/core/cache.d.ts +365 -69
  115. package/types/phaser/core/cache.d.ts.map +1 -1
  116. package/types/phaser/core/const.d.ts +143 -40
  117. package/types/phaser/core/const.d.ts.map +1 -1
  118. package/types/phaser/core/device.d.ts +0 -5
  119. package/types/phaser/core/device.d.ts.map +1 -1
  120. package/types/phaser/core/device_util.d.ts +1 -1
  121. package/types/phaser/core/device_util.d.ts.map +1 -1
  122. package/types/phaser/core/dom.d.ts +119 -0
  123. package/types/phaser/core/dom.d.ts.map +1 -1
  124. package/types/phaser/core/event_manager.d.ts +127 -0
  125. package/types/phaser/core/event_manager.d.ts.map +1 -1
  126. package/types/phaser/core/factory.d.ts +75 -8
  127. package/types/phaser/core/factory.d.ts.map +1 -1
  128. package/types/phaser/core/frame.d.ts +64 -21
  129. package/types/phaser/core/frame.d.ts.map +1 -1
  130. package/types/phaser/core/frame_data.d.ts +61 -9
  131. package/types/phaser/core/frame_data.d.ts.map +1 -1
  132. package/types/phaser/core/frame_util.d.ts +10 -8
  133. package/types/phaser/core/frame_util.d.ts.map +1 -1
  134. package/types/phaser/core/game.d.ts +40 -6
  135. package/types/phaser/core/game.d.ts.map +1 -1
  136. package/types/phaser/core/input.d.ts +143 -15
  137. package/types/phaser/core/input.d.ts.map +1 -1
  138. package/types/phaser/core/input_handler.d.ts +258 -25
  139. package/types/phaser/core/input_handler.d.ts.map +1 -1
  140. package/types/phaser/core/input_mouse.d.ts +62 -14
  141. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  142. package/types/phaser/core/input_mspointer.d.ts +51 -17
  143. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  144. package/types/phaser/core/input_pointer.d.ts +99 -14
  145. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  146. package/types/phaser/core/input_touch.d.ts +53 -16
  147. package/types/phaser/core/input_touch.d.ts.map +1 -1
  148. package/types/phaser/core/loader.d.ts +299 -28
  149. package/types/phaser/core/loader.d.ts.map +1 -1
  150. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  151. package/types/phaser/core/raf.d.ts +19 -9
  152. package/types/phaser/core/raf.d.ts.map +1 -1
  153. package/types/phaser/core/scale_manager.d.ts +208 -13
  154. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  155. package/types/phaser/core/scene.d.ts +21 -5
  156. package/types/phaser/core/scene.d.ts.map +1 -1
  157. package/types/phaser/core/scene_manager.d.ts +90 -10
  158. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  159. package/types/phaser/core/signal.d.ts +93 -9
  160. package/types/phaser/core/signal.d.ts.map +1 -1
  161. package/types/phaser/core/signal_binding.d.ts +34 -5
  162. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  163. package/types/phaser/core/sound.d.ts +111 -14
  164. package/types/phaser/core/sound.d.ts.map +1 -1
  165. package/types/phaser/core/sound_manager.d.ts +97 -11
  166. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  167. package/types/phaser/core/sound_sprite.d.ts +22 -8
  168. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  169. package/types/phaser/core/stage.d.ts +32 -3
  170. package/types/phaser/core/stage.d.ts.map +1 -1
  171. package/types/phaser/core/time.d.ts +73 -6
  172. package/types/phaser/core/time.d.ts.map +1 -1
  173. package/types/phaser/core/timer.d.ts +108 -7
  174. package/types/phaser/core/timer.d.ts.map +1 -1
  175. package/types/phaser/core/timer_event.d.ts +13 -7
  176. package/types/phaser/core/timer_event.d.ts.map +1 -1
  177. package/types/phaser/core/tween.d.ts +124 -4
  178. package/types/phaser/core/tween.d.ts.map +1 -1
  179. package/types/phaser/core/tween_data.d.ts +41 -2
  180. package/types/phaser/core/tween_data.d.ts.map +1 -1
  181. package/types/phaser/core/tween_easing.d.ts +0 -5
  182. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  183. package/types/phaser/core/tween_manager.d.ts +49 -2
  184. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  185. package/types/phaser/core/world.d.ts +9 -1
  186. package/types/phaser/core/world.d.ts.map +1 -1
  187. package/types/phaser/display/bitmap_text.d.ts +84 -7
  188. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  189. package/types/phaser/display/button.d.ts +65 -8
  190. package/types/phaser/display/button.d.ts.map +1 -1
  191. package/types/phaser/display/canvas/buffer.d.ts +20 -4
  192. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  194. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/pool.d.ts +0 -6
  196. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/renderer.d.ts +29 -2
  198. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  200. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  201. package/types/phaser/display/display_object.d.ts +195 -8
  202. package/types/phaser/display/display_object.d.ts.map +1 -1
  203. package/types/phaser/display/graphics.d.ts +132 -6
  204. package/types/phaser/display/graphics.d.ts.map +1 -1
  205. package/types/phaser/display/graphics_data.d.ts +15 -1
  206. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  207. package/types/phaser/display/graphics_data_util.d.ts +3 -2
  208. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  209. package/types/phaser/display/group.d.ts +80 -10
  210. package/types/phaser/display/group.d.ts.map +1 -1
  211. package/types/phaser/display/image.d.ts +72 -6
  212. package/types/phaser/display/image.d.ts.map +1 -1
  213. package/types/phaser/display/sprite_batch.d.ts +4 -3
  214. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  215. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  216. package/types/phaser/display/text.d.ts +366 -46
  217. package/types/phaser/display/text.d.ts.map +1 -1
  218. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  219. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  220. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  221. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  222. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  223. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  224. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  226. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  228. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
  230. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  232. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  234. package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
  235. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  236. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/render_texture.d.ts +30 -3
  238. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/renderer.d.ts +41 -4
  240. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
  242. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
  244. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
  246. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
  248. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
  250. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
  252. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
  254. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  256. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/texture.d.ts +21 -0
  258. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  260. package/types/phaser/display/webgl/util.d.ts +0 -6
  261. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  262. package/types/phaser/geom/circle.d.ts +131 -9
  263. package/types/phaser/geom/circle.d.ts.map +1 -1
  264. package/types/phaser/geom/ellipse.d.ts +43 -5
  265. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  266. package/types/phaser/geom/line.d.ts +159 -13
  267. package/types/phaser/geom/line.d.ts.map +1 -1
  268. package/types/phaser/geom/matrix.d.ts +85 -11
  269. package/types/phaser/geom/matrix.d.ts.map +1 -1
  270. package/types/phaser/geom/point.d.ts +170 -18
  271. package/types/phaser/geom/point.d.ts.map +1 -1
  272. package/types/phaser/geom/polygon.d.ts +45 -5
  273. package/types/phaser/geom/polygon.d.ts.map +1 -1
  274. package/types/phaser/geom/rectangle.d.ts +253 -20
  275. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  276. package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
  277. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  278. package/types/phaser/geom/util/circle.d.ts +3 -3
  279. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  280. package/types/phaser/geom/util/ellipse.d.ts +0 -6
  281. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  282. package/types/phaser/geom/util/line.d.ts +5 -5
  283. package/types/phaser/geom/util/line.d.ts.map +1 -1
  284. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  285. package/types/phaser/geom/util/point.d.ts.map +1 -1
  286. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  287. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  288. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/util/math.d.ts +0 -5
  290. 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 - TBD.
51
+ * @param direction - TBD.
52
+ */
48
53
  setPreloadSprite(sprite, direction = 0) {
49
54
  this.preloadSprite = {
50
55
  sprite,
@@ -64,16 +69,31 @@ 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 - TBD.
84
+ * @param {string} key - TBD.
85
+ * @returns {boolean} TBD.
86
+ */
73
87
  checkKeyExists(type, key) {
74
88
  return this.getAssetIndex(type, key) > -1;
75
89
  }
76
90
 
91
+ /**
92
+ * TBD.
93
+ * @param type - TBD.
94
+ * @param {string} key - TBD.
95
+ * @returns {number} TBD.
96
+ */
77
97
  getAssetIndex(type, key) {
78
98
  let bestFound = -1;
79
99
  for (let i = 0; i < this._fileList.length; i += 1) {
@@ -90,6 +110,12 @@ export class Loader {
90
110
  return bestFound;
91
111
  }
92
112
 
113
+ /**
114
+ * TBD.
115
+ * @param type - TBD.
116
+ * @param {string} key - TBD.
117
+ * @returns {object} TBD.
118
+ */
93
119
  getAsset(type, key) {
94
120
  const fileIndex = this.getAssetIndex(type, key);
95
121
  if (fileIndex > -1) {
@@ -98,6 +124,11 @@ export class Loader {
98
124
  return null;
99
125
  }
100
126
 
127
+ /**
128
+ * TBD.
129
+ * @param hard
130
+ * @param clearEvents
131
+ */
101
132
  reset(hard, clearEvents = false) {
102
133
  if (hard) {
103
134
  this.preloadSprite = null;
@@ -121,14 +152,17 @@ export class Loader {
121
152
  }
122
153
  }
123
154
 
124
- addToFileList(
125
- type,
126
- key = '',
127
- url = null,
128
- properties = null,
129
- overwrite = false,
130
- extension = null
131
- ) {
155
+ /**
156
+ * TBD.
157
+ * @param type - TBD.
158
+ * @param {string} key - TBD.
159
+ * @param {string} url - TBD.
160
+ * @param properties - TBD.
161
+ * @param overwrite - TBD.
162
+ * @param extension - TBD.
163
+ * @returns {Loader} TBD.
164
+ */
165
+ addToFileList(type, key = '', url = null, properties = null, overwrite = false, extension = null) {
132
166
  if (key === undefined || key === '') {
133
167
  console.warn('Loader: Invalid or no key given of type ' + type);
134
168
  return this;
@@ -175,10 +209,26 @@ export class Loader {
175
209
  return this;
176
210
  }
177
211
 
212
+ /**
213
+ * TBD.
214
+ * @param type - TBD.
215
+ * @param {string} key - TBD.
216
+ * @param {string} url - TBD.
217
+ * @param properties - TBD.
218
+ * @returns {Loader} TBD.
219
+ */
178
220
  replaceInFileList(type, key, url, properties) {
179
221
  return this.addToFileList(type, key, url, properties, true);
180
222
  }
181
223
 
224
+ /**
225
+ * TBD.
226
+ * @param {string} key - TBD.
227
+ * @param {string} url - TBD.
228
+ * @param data - TBD.
229
+ * @param {object} callbackContext - TBD.
230
+ * @returns {Loader} TBD.
231
+ */
182
232
  pack(key, url, data, callbackContext) {
183
233
  const pack = {
184
234
  type: 'packfile',
@@ -210,10 +260,23 @@ export class Loader {
210
260
  return this;
211
261
  }
212
262
 
263
+ /**
264
+ * TBD.
265
+ * @param {string} key - TBD.
266
+ * @param {string} url - TBD.
267
+ * @param overwrite - TBD.
268
+ * @returns {Loader} TBD.
269
+ */
213
270
  image(key, url, overwrite) {
214
271
  return this.addToFileList('image', key, url, undefined, overwrite, '.png');
215
272
  }
216
273
 
274
+ /**
275
+ * TBD.
276
+ * @param keys - TBD.
277
+ * @param urls - TBD.
278
+ * @returns {Loader} TBD.
279
+ */
217
280
  images(keys, urls) {
218
281
  if (Array.isArray(urls)) {
219
282
  for (let i = 0; i < keys.length; i += 1) {
@@ -227,18 +290,50 @@ export class Loader {
227
290
  return this;
228
291
  }
229
292
 
293
+ /**
294
+ * TBD.
295
+ * @param {string} key - TBD.
296
+ * @param {string} url - TBD.
297
+ * @param overwrite - TBD.
298
+ * @returns {Loader} TBD.
299
+ */
230
300
  text(key, url, overwrite) {
231
301
  return this.addToFileList('text', key, url, undefined, overwrite, '.txt');
232
302
  }
233
303
 
304
+ /**
305
+ * TBD.
306
+ * @param {string} key - TBD.
307
+ * @param {string} url - TBD.
308
+ * @param overwrite - TBD.
309
+ * @returns {Loader} TBD.
310
+ */
234
311
  json(key, url, overwrite) {
235
312
  return this.addToFileList('json', key, url, undefined, overwrite, '.json');
236
313
  }
237
314
 
315
+ /**
316
+ * TBD.
317
+ * @param {string} key - TBD.
318
+ * @param {string} url - TBD.
319
+ * @param overwrite - TBD.
320
+ * @returns {Loader} TBD.
321
+ */
238
322
  xml(key, url, overwrite) {
239
323
  return this.addToFileList('xml', key, url, undefined, overwrite, '.xml');
240
324
  }
241
325
 
326
+ /**
327
+ * TBD.
328
+ * @param {string} key - TBD.
329
+ * @param {string} url - TBD.
330
+ * @param frameWidth - TBD.
331
+ * @param frameHeight - TBD.
332
+ * @param frameMax - TBD.
333
+ * @param margin - TBD.
334
+ * @param spacing - TBD.
335
+ * @returns {Loader} TBD.
336
+ */
242
337
  spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
243
338
  return this.addToFileList(
244
339
  'spritesheet',
@@ -250,6 +345,13 @@ export class Loader {
250
345
  );
251
346
  }
252
347
 
348
+ /**
349
+ * TBD.
350
+ * @param {string} key - TBD.
351
+ * @param urls
352
+ * @param autoDecode
353
+ * @returns {Loader} TBD.
354
+ */
253
355
  audio(key, urls, autoDecode = true) {
254
356
  if (this.game.sound.noAudio) {
255
357
  return this;
@@ -260,6 +362,15 @@ export class Loader {
260
362
  return this.addToFileList('audio', key, urls, { buffer: null, autoDecode });
261
363
  }
262
364
 
365
+ /**
366
+ * TBD.
367
+ * @param {string} key - TBD.
368
+ * @param urls - TBD.
369
+ * @param jsonURL - TBD.
370
+ * @param jsonData - TBD.
371
+ * @param autoDecode - TBD.
372
+ * @returns {Loader} TBD.
373
+ */
263
374
  audioSprite(key, urls, jsonURL, jsonData, autoDecode = true) {
264
375
  if (this.game.sound.noAudio) {
265
376
  return this;
@@ -276,14 +387,18 @@ export class Loader {
276
387
  return this;
277
388
  }
278
389
 
279
- bitmapFont(
280
- key,
281
- textureURL = null,
282
- atlasURL = null,
283
- atlasData = null,
284
- xSpacing = 0,
285
- ySpacing = 0
286
- ) {
390
+ /**
391
+ * TBD.
392
+ * @param {string} key - TBD.
393
+ * @param textureURL - TBD.
394
+ * @param atlasURL - TBD.
395
+ * @param atlasData - TBD.
396
+ * @param xSpacing - TBD.
397
+ * @param ySpacing - TBD.
398
+ * @returns {Loader} TBD.
399
+ * @throws Error.
400
+ */
401
+ bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
287
402
  if (textureURL === undefined || textureURL === null) {
288
403
  textureURL = key + '.png';
289
404
  }
@@ -316,6 +431,15 @@ export class Loader {
316
431
  return this;
317
432
  }
318
433
 
434
+ /**
435
+ * TBD.
436
+ * @param {string} key - TBD.
437
+ * @param textureURL - TBD.
438
+ * @param atlasURL - TBD.
439
+ * @param atlasData - TBD.
440
+ * @param format - TBD.
441
+ * @returns {Loader} TBD.
442
+ */
319
443
  atlas(key, textureURL, atlasURL = null, atlasData = null, format = TEXTURE_ATLAS_JSON_HASH) {
320
444
  if (textureURL === undefined || textureURL === null) {
321
445
  textureURL = key + '.png';
@@ -332,6 +456,12 @@ export class Loader {
332
456
  return this;
333
457
  }
334
458
 
459
+ /**
460
+ * TBD.
461
+ * @param {Function} callback - TBD.
462
+ * @param {object} callbackContext - TBD.
463
+ * @returns {Loader} TBD.
464
+ */
335
465
  withSyncPoint(callback, callbackContext) {
336
466
  this._withSyncPointDepth += 1;
337
467
  try {
@@ -342,6 +472,12 @@ export class Loader {
342
472
  return this;
343
473
  }
344
474
 
475
+ /**
476
+ * TBD.
477
+ * @param type - TBD.
478
+ * @param {string} key - TBD.
479
+ * @returns {Loader} TBD.
480
+ */
345
481
  addSyncPoint(type, key) {
346
482
  const asset = this.getAsset(type, key);
347
483
  if (asset) {
@@ -350,6 +486,11 @@ export class Loader {
350
486
  return this;
351
487
  }
352
488
 
489
+ /**
490
+ * TBD.
491
+ * @param type - TBD.
492
+ * @param {string} key - TBD.
493
+ */
353
494
  removeFile(type, key) {
354
495
  const asset = this.getAsset(type, key);
355
496
  if (asset) {
@@ -359,11 +500,17 @@ export class Loader {
359
500
  }
360
501
  }
361
502
 
503
+ /**
504
+ * TBD.
505
+ */
362
506
  removeAll() {
363
507
  this._fileList.length = 0;
364
508
  this._flightQueue.length = 0;
365
509
  }
366
510
 
511
+ /**
512
+ * TBD.
513
+ */
367
514
  start() {
368
515
  if (this.isLoading) {
369
516
  return;
@@ -374,6 +521,9 @@ export class Loader {
374
521
  this.processLoadQueue();
375
522
  }
376
523
 
524
+ /**
525
+ * TBD.
526
+ */
377
527
  processLoadQueue() {
378
528
  if (!this.isLoading) {
379
529
  console.warn('Loader - active loading canceled / reset');
@@ -404,12 +554,7 @@ export class Loader {
404
554
  } else if (file.type === 'packfile' && file.error) {
405
555
  // Non-error pack files are handled when processing the file queue
406
556
  this._loadedPackCount += 1;
407
- this.onPackComplete.dispatch(
408
- file.key,
409
- !file.error,
410
- this._loadedPackCount,
411
- this._totalPackCount
412
- );
557
+ this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
413
558
  }
414
559
  }
415
560
  }
@@ -423,12 +568,7 @@ export class Loader {
423
568
  // Processing the pack / adds more files
424
569
  this.processPack(file);
425
570
  this._loadedPackCount += 1;
426
- this.onPackComplete.dispatch(
427
- file.key,
428
- !file.error,
429
- this._loadedPackCount,
430
- this._totalPackCount
431
- );
571
+ this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
432
572
  }
433
573
  if (file.loaded || file.error) {
434
574
  // Item at the start of file list finished, can skip it in future
@@ -459,10 +599,7 @@ export class Loader {
459
599
  }
460
600
  // Stop looking if queue full - or if syncblocked and there are no more packs.
461
601
  // (As only packs can be loaded around a syncblock)
462
- if (
463
- this._flightQueue.length >= inflightLimit ||
464
- (syncblock && this._loadedPackCount === this._totalPackCount)
465
- ) {
602
+ if (this._flightQueue.length >= inflightLimit || (syncblock && this._loadedPackCount === this._totalPackCount)) {
466
603
  break;
467
604
  }
468
605
  }
@@ -482,6 +619,10 @@ export class Loader {
482
619
  }
483
620
  }
484
621
 
622
+ /**
623
+ * TBD.
624
+ * @param abnormal - TBD.
625
+ */
485
626
  finishedLoading(abnormal) {
486
627
  if (this.hasLoaded) {
487
628
  return;
@@ -501,6 +642,11 @@ export class Loader {
501
642
  // this.reset();
502
643
  }
503
644
 
645
+ /**
646
+ * TBD.
647
+ * @param file - TBD.
648
+ * @param errorMessage - TBD.
649
+ */
504
650
  asyncComplete(file, errorMessage = '') {
505
651
  file.loaded = true;
506
652
  file.error = !!errorMessage;
@@ -512,6 +658,10 @@ export class Loader {
512
658
  this.processLoadQueue();
513
659
  }
514
660
 
661
+ /**
662
+ * TBD.
663
+ * @param pack - TBD.
664
+ */
515
665
  processPack(pack) {
516
666
  const packData = pack.data[pack.key];
517
667
  if (!packData) {
@@ -565,18 +715,18 @@ export class Loader {
565
715
  );
566
716
  break;
567
717
  case 'atlas':
568
- this.atlas(
569
- file.key,
570
- file.textureURL,
571
- file.atlasURL,
572
- file.atlasData,
573
- TEXTURE_ATLAS_JSON_HASH
574
- );
718
+ this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
575
719
  break;
576
720
  }
577
721
  }
578
722
  }
579
723
 
724
+ /**
725
+ * TBD.
726
+ * @param {string} url - TBD.
727
+ * @param file - TBD.
728
+ * @returns {string} TBD.
729
+ */
580
730
  transformUrl(url, file) {
581
731
  if (!url) {
582
732
  return false;
@@ -587,6 +737,10 @@ export class Loader {
587
737
  return this.baseURL + file.path + url;
588
738
  }
589
739
 
740
+ /**
741
+ * TBD.
742
+ * @param file - TBD.
743
+ */
590
744
  loadFile(file) {
591
745
  switch (file.type) {
592
746
  case 'packfile':
@@ -603,11 +757,7 @@ export class Loader {
603
757
  if (file.url) {
604
758
  this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
605
759
  } else {
606
- this.fileError(
607
- file,
608
- null,
609
- 'No supported audio URL specified or device does not have audio playback support'
610
- );
760
+ this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
611
761
  }
612
762
  break;
613
763
  case 'json':
@@ -625,6 +775,10 @@ export class Loader {
625
775
  }
626
776
  }
627
777
 
778
+ /**
779
+ * TBD.
780
+ * @param file - TBD.
781
+ */
628
782
  loadImageTag(file) {
629
783
  this.log('loadImageTag', file);
630
784
  const scope = this;
@@ -653,6 +807,14 @@ export class Loader {
653
807
  file.data.src = this.transformUrl(file.url, file);
654
808
  }
655
809
 
810
+ /**
811
+ * TBD.
812
+ * @param file - TBD.
813
+ * @param {string} url - TBD.
814
+ * @param type - TBD.
815
+ * @param onload - TBD.
816
+ * @param onerror - TBD.
817
+ */
656
818
  xhrLoad(file, url, type, onload, onerror) {
657
819
  this.log('xhrLoad', file);
658
820
  const scope = this;
@@ -712,11 +874,19 @@ export class Loader {
712
874
  xhr.send();
713
875
  }
714
876
 
877
+ /**
878
+ * TBD.
879
+ */
715
880
  xhrLoadWithXDR() {
716
881
  // TODO
717
882
  console.warn('loader.xhrLoadWithXDR() is not implemented');
718
883
  }
719
884
 
885
+ /**
886
+ * TBD.
887
+ * @param urls - TBD.
888
+ * @returns {string} TBD.
889
+ */
720
890
  getAudioURL(urls) {
721
891
  if (this.game.sound.noAudio) {
722
892
  return null;
@@ -750,6 +920,12 @@ export class Loader {
750
920
  return null;
751
921
  }
752
922
 
923
+ /**
924
+ * TBD.
925
+ * @param file - TBD.
926
+ * @param xhr - TBD.
927
+ * @param reason - TBD.
928
+ */
753
929
  fileError(file, xhr, reason) {
754
930
  // const url = file.requestUrl || this.transformUrl(file.url, file);
755
931
  let message = 'Error loading asset';
@@ -762,6 +938,12 @@ export class Loader {
762
938
  this.asyncComplete(file, message);
763
939
  }
764
940
 
941
+ /**
942
+ * TBD.
943
+ * @param file - TBD.
944
+ * @param xhr - TBD.
945
+ * @throws Error.
946
+ */
765
947
  fileComplete(file, xhr) {
766
948
  let loadNext = true;
767
949
  switch (file.type) {
@@ -790,12 +972,7 @@ export class Loader {
790
972
  } else {
791
973
  loadNext = false;
792
974
  if (file.format === TEXTURE_ATLAS_JSON_HASH) {
793
- this.xhrLoad(
794
- file,
795
- this.transformUrl(file.atlasURL, file),
796
- 'text',
797
- this.jsonLoadComplete
798
- );
975
+ this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
799
976
  } else {
800
977
  throw new Error('Invalid Texture Atlas format: ' + file.format);
801
978
  }
@@ -815,27 +992,22 @@ export class Loader {
815
992
  } else {
816
993
  // Load the XML before carrying on with the next file
817
994
  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
- }
995
+ this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', (bitmapFontFile, bitmapFontXhr) => {
996
+ let json;
997
+ try {
998
+ // Try to parse as JSON, if it fails, then it's hopefully XML
999
+ json = JSON.parse(bitmapFontXhr.responseText);
1000
+ } catch (e) {
1001
+ // pass
837
1002
  }
838
- );
1003
+ if (json) {
1004
+ bitmapFontFile.atlasType = 'json';
1005
+ this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
1006
+ } else {
1007
+ bitmapFontFile.atlasType = 'xml';
1008
+ this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
1009
+ }
1010
+ });
839
1011
  }
840
1012
  break;
841
1013
  case 'audio':
@@ -858,18 +1030,15 @@ export class Loader {
858
1030
  }
859
1031
  }
860
1032
 
1033
+ /**
1034
+ * TBD.
1035
+ * @param file - TBD.
1036
+ * @param xhr - TBD.
1037
+ */
861
1038
  jsonLoadComplete(file, xhr) {
862
1039
  const data = JSON.parse(xhr.responseText);
863
1040
  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
- );
1041
+ this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
873
1042
  } else if (file.type === 'json') {
874
1043
  this.cache.addJSON(file.key, file.url, data);
875
1044
  } else {
@@ -878,11 +1047,19 @@ export class Loader {
878
1047
  this.asyncComplete(file);
879
1048
  }
880
1049
 
1050
+ /**
1051
+ * TBD.
1052
+ */
881
1053
  csvLoadComplete() {
882
1054
  // TODO
883
1055
  console.warn('loader.csvLoadComplete() is not implemented');
884
1056
  }
885
1057
 
1058
+ /**
1059
+ * TBD.
1060
+ * @param file - TBD.
1061
+ * @param xhr - TBD.
1062
+ */
886
1063
  xmlLoadComplete(file, xhr) {
887
1064
  // Always try parsing the content as XML, regardless of actually response type
888
1065
  const data = xhr.responseText;
@@ -894,15 +1071,7 @@ export class Loader {
894
1071
  return;
895
1072
  }
896
1073
  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
- );
1074
+ this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
906
1075
  } else if (file.type === 'textureatlas') {
907
1076
  this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
908
1077
  } else if (file.type === 'xml') {
@@ -911,6 +1080,11 @@ export class Loader {
911
1080
  this.asyncComplete(file);
912
1081
  }
913
1082
 
1083
+ /**
1084
+ * TBD.
1085
+ * @param data - TBD.
1086
+ * @returns {Document} TBD.
1087
+ */
914
1088
  parseXml(data) {
915
1089
  let xml = null;
916
1090
  try {
@@ -932,16 +1106,15 @@ export class Loader {
932
1106
  return xml;
933
1107
  }
934
1108
 
1109
+ /**
1110
+ * TBD.
1111
+ */
935
1112
  updateProgress() {
936
1113
  if (this.preloadSprite) {
937
1114
  if (this.preloadSprite.direction === 0) {
938
- this.preloadSprite.rect.width = Math.floor(
939
- (this.preloadSprite.width / 100) * this.progress
940
- );
1115
+ this.preloadSprite.rect.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
941
1116
  } else {
942
- this.preloadSprite.rect.height = Math.floor(
943
- (this.preloadSprite.height / 100) * this.progress
944
- );
1117
+ this.preloadSprite.rect.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
945
1118
  }
946
1119
  if (this.preloadSprite.sprite) {
947
1120
  this.preloadSprite.sprite.updateCrop();
@@ -952,6 +1125,11 @@ export class Loader {
952
1125
  }
953
1126
  }
954
1127
 
1128
+ /**
1129
+ * TBD.
1130
+ * @param message - TBD.
1131
+ * @param data - TBD.
1132
+ */
955
1133
  log(message, data = '') {
956
1134
  if (!this.isUseLog) {
957
1135
  return;
@@ -959,27 +1137,51 @@ export class Loader {
959
1137
  console.log(`[Loader] ${message}`, data);
960
1138
  }
961
1139
 
1140
+ /**
1141
+ * TBD.
1142
+ * @returns {number} TBD.
1143
+ */
962
1144
  totalLoadedFiles() {
963
1145
  return this._loadedFileCount;
964
1146
  }
965
1147
 
1148
+ /**
1149
+ * TBD.
1150
+ * @returns {number} TBD.
1151
+ */
966
1152
  totalQueuedFiles() {
967
1153
  return this._totalFileCount - this._loadedFileCount;
968
1154
  }
969
1155
 
1156
+ /**
1157
+ * TBD.
1158
+ * @returns {number} TBD.
1159
+ */
970
1160
  totalLoadedPacks() {
971
1161
  return this._totalPackCount;
972
1162
  }
973
1163
 
1164
+ /**
1165
+ * TBD.
1166
+ * @returns {number} TBD.
1167
+ */
974
1168
  totalQueuedPacks() {
975
1169
  return this._totalPackCount - this._loadedPackCount;
976
1170
  }
977
1171
 
1172
+ /**
1173
+ * TBD.
1174
+ * @returns {number} TBD.
1175
+ */
978
1176
  get progressFloat() {
979
1177
  const progress = (this._loadedFileCount / this._totalFileCount) * 100;
980
1178
  return Math.max(0, Math.min(100, progress || 0));
981
1179
  }
982
1180
 
1181
+ /**
1182
+ * TBD.
1183
+ * @returns {number} TBD.
1184
+ */
983
1185
  get progress() {
984
1186
  return Math.round(this.progressFloat);
985
1187
  }