@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,16 +1,15 @@
1
1
  /**
2
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
3
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
4
  * @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
5
  */
6
- import Signal from './signal';
7
- import Rectangle from '../geom/rectangle';
6
+ import { Signal } from './signal';
7
+ import { Rectangle } from '../geom/rectangle';
8
8
  import { canPlayAudio } from './device_util';
9
9
 
10
10
  const TEXTURE_ATLAS_JSON_HASH = 1;
11
11
 
12
12
  export default class {
13
-
14
13
  constructor(game) {
15
14
  this.game = game;
16
15
  this.cache = game.cache;
@@ -122,7 +121,14 @@ export default class {
122
121
  }
123
122
  }
124
123
 
125
- addToFileList(type, key = '', url = null, properties = null, overwrite = false, extension = null) {
124
+ addToFileList(
125
+ type,
126
+ key = '',
127
+ url = null,
128
+ properties = null,
129
+ overwrite = false,
130
+ extension = null
131
+ ) {
126
132
  if (key === undefined || key === '') {
127
133
  console.warn('Loader: Invalid or no key given of type ' + type);
128
134
  return this;
@@ -184,7 +190,7 @@ export default class {
184
190
  loading: false,
185
191
  loaded: false,
186
192
  error: false,
187
- callbackContext: callbackContext
193
+ callbackContext: callbackContext,
188
194
  };
189
195
  if (data) {
190
196
  if (typeof data === 'string') {
@@ -234,7 +240,14 @@ export default class {
234
240
  }
235
241
 
236
242
  spritesheet(key, url, frameWidth, frameHeight, frameMax = -1, margin = 0, spacing = 0) {
237
- return this.addToFileList('spritesheet', key, url, { frameWidth, frameHeight, frameMax, margin, spacing }, false, '.png');
243
+ return this.addToFileList(
244
+ 'spritesheet',
245
+ key,
246
+ url,
247
+ { frameWidth, frameHeight, frameMax, margin, spacing },
248
+ false,
249
+ '.png'
250
+ );
238
251
  }
239
252
 
240
253
  audio(key, urls, autoDecode = true) {
@@ -263,7 +276,14 @@ export default class {
263
276
  return this;
264
277
  }
265
278
 
266
- bitmapFont(key, textureURL = null, atlasURL = null, atlasData = null, xSpacing = 0, ySpacing = 0) {
279
+ bitmapFont(
280
+ key,
281
+ textureURL = null,
282
+ atlasURL = null,
283
+ atlasData = null,
284
+ xSpacing = 0,
285
+ ySpacing = 0
286
+ ) {
267
287
  if (textureURL === undefined || textureURL === null) {
268
288
  textureURL = key + '.png';
269
289
  }
@@ -285,7 +305,13 @@ export default class {
285
305
  if (!xml && !json) {
286
306
  throw new Error('Loader. Invalid Bitmap Font atlas given');
287
307
  }
288
- this.addToFileList('bitmapfont', key, textureURL, { atlasURL: null, atlasData: json || xml, atlasType: (json ? 'json' : 'xml'), xSpacing, ySpacing });
308
+ this.addToFileList('bitmapfont', key, textureURL, {
309
+ atlasURL: null,
310
+ atlasData: json || xml,
311
+ atlasType: json ? 'json' : 'xml',
312
+ xSpacing,
313
+ ySpacing,
314
+ });
289
315
  }
290
316
  return this;
291
317
  }
@@ -368,11 +394,22 @@ export default class {
368
394
  }
369
395
  if (file.type !== 'packfile') {
370
396
  this._loadedFileCount += 1;
371
- this.onFileComplete.dispatch(this.progress, file.key, !file.error, this._loadedFileCount, this._totalFileCount);
397
+ this.onFileComplete.dispatch(
398
+ this.progress,
399
+ file.key,
400
+ !file.error,
401
+ this._loadedFileCount,
402
+ this._totalFileCount
403
+ );
372
404
  } else if (file.type === 'packfile' && file.error) {
373
405
  // Non-error pack files are handled when processing the file queue
374
406
  this._loadedPackCount += 1;
375
- this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
407
+ this.onPackComplete.dispatch(
408
+ file.key,
409
+ !file.error,
410
+ this._loadedPackCount,
411
+ this._totalPackCount
412
+ );
376
413
  }
377
414
  }
378
415
  }
@@ -386,7 +423,12 @@ export default class {
386
423
  // Processing the pack / adds more files
387
424
  this.processPack(file);
388
425
  this._loadedPackCount += 1;
389
- this.onPackComplete.dispatch(file.key, !file.error, this._loadedPackCount, this._totalPackCount);
426
+ this.onPackComplete.dispatch(
427
+ file.key,
428
+ !file.error,
429
+ this._loadedPackCount,
430
+ this._totalPackCount
431
+ );
390
432
  }
391
433
  if (file.loaded || file.error) {
392
434
  // Item at the start of file list finished, can skip it in future
@@ -417,7 +459,10 @@ export default class {
417
459
  }
418
460
  // Stop looking if queue full - or if syncblocked and there are no more packs.
419
461
  // (As only packs can be loaded around a syncblock)
420
- if (this._flightQueue.length >= inflightLimit || (syncblock && this._loadedPackCount === this._totalPackCount)) {
462
+ if (
463
+ this._flightQueue.length >= inflightLimit ||
464
+ (syncblock && this._loadedPackCount === this._totalPackCount)
465
+ ) {
421
466
  break;
422
467
  }
423
468
  }
@@ -477,35 +522,56 @@ export default class {
477
522
  for (let i = 0; i < packDataCompat.length; i += 1) {
478
523
  const file = packDataCompat[i];
479
524
  switch (file.type) {
480
- case "image":
525
+ case 'image':
481
526
  this.image(file.key, file.url, file.overwrite);
482
527
  break;
483
- case "text":
528
+ case 'text':
484
529
  this.text(file.key, file.url, file.overwrite);
485
530
  break;
486
- case "json":
531
+ case 'json':
487
532
  this.json(file.key, file.url, file.overwrite);
488
533
  break;
489
- case "xml":
534
+ case 'xml':
490
535
  this.xml(file.key, file.url, file.overwrite);
491
536
  break;
492
- case "spritesheet":
493
- this.spritesheet(file.key, file.url, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
537
+ case 'spritesheet':
538
+ this.spritesheet(
539
+ file.key,
540
+ file.url,
541
+ file.frameWidth,
542
+ file.frameHeight,
543
+ file.frameMax,
544
+ file.margin,
545
+ file.spacing
546
+ );
494
547
  break;
495
- case "audio":
548
+ case 'audio':
496
549
  this.audio(file.key, file.urls ? file.urls : file.url);
497
550
  break;
498
- case "audiosprite":
551
+ case 'audiosprite':
499
552
  this.audioSprite(file.key, file.urls ? file.urls : file.url, file.jsonURL, file.jsonData);
500
553
  break;
501
- case "audioSprite":
554
+ case 'audioSprite':
502
555
  this.audioSprite(file.key, file.audioURL, file.jsonURL, file.jsonData);
503
556
  break;
504
- case "bitmapFont":
505
- this.bitmapFont(file.key, file.textureURL, file.fontDataURL ? file.fontDataURL : file.atlasURL, file.atlasData, file.xSpacing, file.ySpacing);
557
+ case 'bitmapFont':
558
+ this.bitmapFont(
559
+ file.key,
560
+ file.textureURL,
561
+ file.fontDataURL ? file.fontDataURL : file.atlasURL,
562
+ file.atlasData,
563
+ file.xSpacing,
564
+ file.ySpacing
565
+ );
506
566
  break;
507
- case "atlas":
508
- this.atlas(file.key, file.textureURL, file.atlasURL, file.atlasData, TEXTURE_ATLAS_JSON_HASH);
567
+ case 'atlas':
568
+ this.atlas(
569
+ file.key,
570
+ file.textureURL,
571
+ file.atlasURL,
572
+ file.atlasData,
573
+ TEXTURE_ATLAS_JSON_HASH
574
+ );
509
575
  break;
510
576
  }
511
577
  }
@@ -537,7 +603,11 @@ export default class {
537
603
  if (file.url) {
538
604
  this.xhrLoad(file, this.transformUrl(file.url, file), 'arraybuffer', this.fileComplete);
539
605
  } else {
540
- this.fileError(file, null, 'No supported audio URL specified or device does not have audio playback support');
606
+ this.fileError(
607
+ file,
608
+ null,
609
+ 'No supported audio URL specified or device does not have audio playback support'
610
+ );
541
611
  }
542
612
  break;
543
613
  case 'json':
@@ -572,7 +642,7 @@ export default class {
572
642
  };
573
643
  file.data.onerror = () => {
574
644
  if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
575
- file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
645
+ file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
576
646
  scope.loadImageTag(file);
577
647
  } else if (file.data.onload) {
578
648
  file.data.onload = null;
@@ -598,9 +668,10 @@ export default class {
598
668
  onerror = onerror || this.fileError;
599
669
  xhr.onload = () => {
600
670
  try {
601
- if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) { // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
671
+ if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) {
672
+ // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
602
673
  if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
603
- file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
674
+ file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
604
675
  scope.xhrLoad(file, url, type, onload, onerror);
605
676
  return null;
606
677
  } else {
@@ -621,7 +692,7 @@ export default class {
621
692
  };
622
693
  xhr.onerror = () => {
623
694
  if (scope.isUseRetry && (!file.numRetry || file.numRetry < scope.maxRetry)) {
624
- file.numRetry = !file.numRetry ? 1 : file.numRetry += 1;
695
+ file.numRetry = !file.numRetry ? 1 : (file.numRetry += 1);
625
696
  scope.xhrLoad(file, url, type, onload, onerror);
626
697
  } else {
627
698
  try {
@@ -702,7 +773,16 @@ export default class {
702
773
  this.cache.addImage(file.key, file.url, file.data);
703
774
  break;
704
775
  case 'spritesheet':
705
- this.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax, file.margin, file.spacing);
776
+ this.cache.addSpriteSheet(
777
+ file.key,
778
+ file.url,
779
+ file.data,
780
+ file.frameWidth,
781
+ file.frameHeight,
782
+ file.frameMax,
783
+ file.margin,
784
+ file.spacing
785
+ );
706
786
  break;
707
787
  case 'textureatlas':
708
788
  if (file.atlasURL == null) {
@@ -710,7 +790,12 @@ export default class {
710
790
  } else {
711
791
  loadNext = false;
712
792
  if (file.format === TEXTURE_ATLAS_JSON_HASH) {
713
- this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', this.jsonLoadComplete);
793
+ this.xhrLoad(
794
+ file,
795
+ this.transformUrl(file.atlasURL, file),
796
+ 'text',
797
+ this.jsonLoadComplete
798
+ );
714
799
  } else {
715
800
  throw new Error('Invalid Texture Atlas format: ' + file.format);
716
801
  }
@@ -718,26 +803,39 @@ export default class {
718
803
  break;
719
804
  case 'bitmapfont':
720
805
  if (!file.atlasURL) {
721
- this.cache.addBitmapFont(file.key, file.url, file.data, file.atlasData, file.atlasType, file.xSpacing, file.ySpacing);
806
+ this.cache.addBitmapFont(
807
+ file.key,
808
+ file.url,
809
+ file.data,
810
+ file.atlasData,
811
+ file.atlasType,
812
+ file.xSpacing,
813
+ file.ySpacing
814
+ );
722
815
  } else {
723
816
  // Load the XML before carrying on with the next file
724
817
  loadNext = false;
725
- this.xhrLoad(file, this.transformUrl(file.atlasURL, file), 'text', (bitmapFontFile, bitmapFontXhr) => {
726
- let json;
727
- try {
728
- // Try to parse as JSON, if it fails, then it's hopefully XML
729
- json = JSON.parse(bitmapFontXhr.responseText);
730
- } catch (e) {
731
- // pass
732
- }
733
- if (json) {
734
- bitmapFontFile.atlasType = 'json';
735
- this.jsonLoadComplete(bitmapFontFile, bitmapFontXhr);
736
- } else {
737
- bitmapFontFile.atlasType = 'xml';
738
- this.xmlLoadComplete(bitmapFontFile, bitmapFontXhr);
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
+ }
739
837
  }
740
- });
838
+ );
741
839
  }
742
840
  break;
743
841
  case 'audio':
@@ -763,7 +861,15 @@ export default class {
763
861
  jsonLoadComplete(file, xhr) {
764
862
  const data = JSON.parse(xhr.responseText);
765
863
  if (file.type === 'bitmapfont') {
766
- this.cache.addBitmapFont(file.key, file.url, file.data, data, file.atlasType, file.xSpacing, file.ySpacing);
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
+ );
767
873
  } else if (file.type === 'json') {
768
874
  this.cache.addJSON(file.key, file.url, data);
769
875
  } else {
@@ -788,7 +894,15 @@ export default class {
788
894
  return;
789
895
  }
790
896
  if (file.type === 'bitmapfont') {
791
- this.cache.addBitmapFont(file.key, file.url, file.data, xml, file.atlasType, file.xSpacing, file.ySpacing);
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
+ );
792
906
  } else if (file.type === 'textureatlas') {
793
907
  this.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
794
908
  } else if (file.type === 'xml') {
@@ -821,9 +935,13 @@ export default class {
821
935
  updateProgress() {
822
936
  if (this.preloadSprite) {
823
937
  if (this.preloadSprite.direction === 0) {
824
- this.preloadSprite.rect.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
938
+ this.preloadSprite.rect.width = Math.floor(
939
+ (this.preloadSprite.width / 100) * this.progress
940
+ );
825
941
  } else {
826
- this.preloadSprite.rect.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
942
+ this.preloadSprite.rect.height = Math.floor(
943
+ (this.preloadSprite.height / 100) * this.progress
944
+ );
827
945
  }
828
946
  if (this.preloadSprite.sprite) {
829
947
  this.preloadSprite.sprite.updateCrop();
@@ -865,5 +983,4 @@ export default class {
865
983
  get progress() {
866
984
  return Math.round(this.progressFloat);
867
985
  }
868
-
869
986
  }
@@ -1,32 +1,37 @@
1
1
  /**
2
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
3
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
4
  * @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
5
  */
6
- import Texture from '../display/webgl/texture';
7
- import Rectangle from '../geom/rectangle';
6
+ import { Texture } from '../display/webgl/texture';
7
+ import { Rectangle } from '../geom/rectangle';
8
8
 
9
9
  /**
10
+ * TBD.
10
11
  *
11
- * @param {object} baseTexture TBD
12
- * @param {object} bitmapFontData TBD
13
- * @returns {object} TBD
12
+ * @param {object} baseTexture - TBD.
13
+ * @param {object} bitmapFontData - TBD.
14
+ * @returns {object} TBD.
14
15
  */
15
16
  export function finalizeBitmapFont(baseTexture, bitmapFontData) {
16
17
  Object.keys(bitmapFontData.chars).forEach((charCode) => {
17
18
  const letter = bitmapFontData.chars[charCode];
18
- letter.texture = new Texture(baseTexture, new Rectangle(letter.x, letter.y, letter.width, letter.height));
19
+ letter.texture = new Texture(
20
+ baseTexture,
21
+ new Rectangle(letter.x, letter.y, letter.width, letter.height)
22
+ );
19
23
  });
20
24
  return bitmapFontData;
21
25
  }
22
26
 
23
27
  /**
28
+ * TBD.
24
29
  *
25
- * @param {object} xml TBD
26
- * @param {object} baseTexture TBD
27
- * @param {number} xSpacing TBD
28
- * @param {number} ySpacing TBD
29
- * @returns {object} TBD
30
+ * @param {object} xml - TBD.
31
+ * @param {object} baseTexture - TBD.
32
+ * @param {number} xSpacing - TBD.
33
+ * @param {number} ySpacing - TBD.
34
+ * @returns {object} TBD.
30
35
  */
31
36
  export function xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing) {
32
37
  const data = {};
@@ -61,24 +66,26 @@ export function xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing) {
61
66
  }
62
67
 
63
68
  /**
69
+ * TBD.
64
70
  *
65
- * @param {object} xml TBD
66
- * @param {object} baseTexture TBD
67
- * @param {number} xSpacing TBD
68
- * @param {number} ySpacing TBD
69
- * @returns {object} TBD
71
+ * @param {object} xml - TBD.
72
+ * @param {object} baseTexture - TBD.
73
+ * @param {number} xSpacing - TBD.
74
+ * @param {number} ySpacing - TBD.
75
+ * @returns {object} TBD.
70
76
  */
71
77
  export function bitmapFont(xml, baseTexture, xSpacing, ySpacing) {
72
78
  return xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing);
73
79
  }
74
80
 
75
81
  /**
82
+ * TBD.
76
83
  *
77
- * @param {object} json TBD
78
- * @param {object} baseTexture TBD
79
- * @param {number} xSpacing TBD
80
- * @param {number} ySpacing TBD
81
- * @returns {object} TBD
84
+ * @param {object} json - TBD.
85
+ * @param {object} baseTexture - TBD.
86
+ * @param {number} xSpacing - TBD.
87
+ * @param {number} ySpacing - TBD.
88
+ * @returns {object} TBD.
82
89
  */
83
90
  export function jsonBitmapFont(json, baseTexture, xSpacing, ySpacing) {
84
91
  const data = {
@@ -1,10 +1,9 @@
1
1
  /**
2
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
3
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
4
  * @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
5
  */
6
- export default class {
7
-
6
+ export class RequestAnimationFrame {
8
7
  constructor(game) {
9
8
  this.game = game;
10
9
  this.rafId = 0;
@@ -23,5 +22,4 @@ export default class {
23
22
  this.game.update(rafTime);
24
23
  this.rafId = requestAnimationFrame(this.updateBinded);
25
24
  }
26
-
27
25
  }