@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,44 +1,44 @@
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
- constructor(game, key) {
8
- this.game = game;
9
- this.key = key;
10
- this.config = this.game.cache.getJSON(key + '-audioatlas');
11
- this.autoplayKey = null;
12
- this.autoplay = false;
13
- this.sounds = {};
14
- for (let k in this.config.spritemap) {
15
- const marker = this.config.spritemap[k];
16
- const sound = this.game.sound.add(this.key);
17
- sound.addMarker(k, marker.start, (marker.end - marker.start), null, marker.loop);
18
- this.sounds[k] = sound;
19
- }
20
- if (this.config.autoplay) {
21
- this.autoplayKey = this.config.autoplay;
22
- this.play(this.autoplayKey);
23
- this.autoplay = this.sounds[this.autoplayKey];
24
- }
6
+ export class SoundSprite {
7
+ constructor(game, key) {
8
+ this.game = game;
9
+ this.key = key;
10
+ this.config = this.game.cache.getJSON(key + '-audioatlas');
11
+ this.autoplayKey = null;
12
+ this.autoplay = false;
13
+ this.sounds = {};
14
+ for (let k in this.config.spritemap) {
15
+ const marker = this.config.spritemap[k];
16
+ const sound = this.game.sound.add(this.key);
17
+ sound.addMarker(k, marker.start, marker.end - marker.start, null, marker.loop);
18
+ this.sounds[k] = sound;
25
19
  }
26
-
27
- play(marker, volume = 1) {
28
- return this.sounds[marker].play(marker, null, volume);
20
+ if (this.config.autoplay) {
21
+ this.autoplayKey = this.config.autoplay;
22
+ this.play(this.autoplayKey);
23
+ this.autoplay = this.sounds[this.autoplayKey];
29
24
  }
25
+ }
30
26
 
31
- stop(marker) {
32
- if (!marker) {
33
- for (let key in this.sounds) {
34
- this.sounds[key].stop();
35
- }
36
- } else {
37
- this.sounds[marker].stop();
38
- }
39
- }
27
+ play(marker, volume = 1) {
28
+ return this.sounds[marker].play(marker, null, volume);
29
+ }
40
30
 
41
- get(marker) {
42
- return this.sounds[marker];
31
+ stop(marker) {
32
+ if (!marker) {
33
+ for (let key in this.sounds) {
34
+ this.sounds[key].stop();
35
+ }
36
+ } else {
37
+ this.sounds[marker].stop();
43
38
  }
39
+ }
40
+
41
+ get(marker) {
42
+ return this.sounds[marker];
43
+ }
44
44
  }
@@ -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 Matrix from '../geom/matrix';
7
- import DisplayObject from '../display/display_object';
6
+ import { Matrix } from '../geom/matrix';
7
+ import { DisplayObject } from '../display/display_object';
8
8
  import { setUserSelect, setTouchAction } from '../display/canvas/util';
9
9
  import { valueToColor } from '../util/math';
10
10
  import { SCALE_LINEAR, SCALE_NEAREST } from './const';
11
11
 
12
- export default class extends DisplayObject {
13
-
12
+ export class Stage extends DisplayObject {
14
13
  constructor(game) {
15
14
  super();
16
15
  this.game = game;
@@ -103,6 +102,4 @@ export default class extends DisplayObject {
103
102
  set smoothed(value) {
104
103
  window.PhaserRegistry.TEXTURE_SCALE_MODE = value ? SCALE_LINEAR : SCALE_NEAREST;
105
104
  }
106
-
107
-
108
105
  }
@@ -1,12 +1,11 @@
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 Timer from './timer';
7
-
8
- export default class {
6
+ import { Timer } from './timer';
9
7
 
8
+ export class Time {
10
9
  constructor(game) {
11
10
  this.game = game;
12
11
  this.time = 0;
@@ -184,5 +183,4 @@ export default class {
184
183
  this._desiredFps = value;
185
184
  this.desiredFpsMult = 1.0 / value;
186
185
  }
187
-
188
186
  }
@@ -1,13 +1,12 @@
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';
6
+ import { Signal } from './signal';
7
7
  import TimerEvent from './timer_event';
8
8
 
9
- export default class {
10
-
9
+ export class Timer {
11
10
  constructor(game, autoDestroy = false) {
12
11
  this.game = game;
13
12
  this.running = false;
@@ -39,7 +38,16 @@ export default class {
39
38
  } else {
40
39
  tick += this._now;
41
40
  }
42
- const event = new TimerEvent(this, roundedDelay, tick, repeatCount, loop, callback, callbackContext, args);
41
+ const event = new TimerEvent(
42
+ this,
43
+ roundedDelay,
44
+ tick,
45
+ repeatCount,
46
+ loop,
47
+ callback,
48
+ callbackContext,
49
+ args
50
+ );
43
51
  this.events.push(event);
44
52
  this.order();
45
53
  this.expired = false;
@@ -135,21 +143,31 @@ export default class {
135
143
  while (this._i < this._len && this.running) {
136
144
  if (this._now >= this.events[this._i].tick && !this.events[this._i].pendingDelete) {
137
145
  // (now + delay) - (time difference from last tick to now)
138
- this._newTick = (this._now + this.events[this._i].delay) - (this._now - this.events[this._i].tick);
146
+ this._newTick =
147
+ this._now + this.events[this._i].delay - (this._now - this.events[this._i].tick);
139
148
  if (this._newTick < 0) {
140
149
  this._newTick = this._now + this.events[this._i].delay;
141
150
  }
142
151
  if (this.events[this._i].loop === true) {
143
152
  this.events[this._i].tick = this._newTick;
144
- this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
153
+ this.events[this._i].callback.apply(
154
+ this.events[this._i].callbackContext,
155
+ this.events[this._i].args
156
+ );
145
157
  } else if (this.events[this._i].repeatCount > 0) {
146
158
  this.events[this._i].repeatCount -= 1;
147
159
  this.events[this._i].tick = this._newTick;
148
- this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
160
+ this.events[this._i].callback.apply(
161
+ this.events[this._i].callbackContext,
162
+ this.events[this._i].args
163
+ );
149
164
  } else {
150
165
  this._marked += 1;
151
166
  this.events[this._i].pendingDelete = true;
152
- this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args);
167
+ this.events[this._i].callback.apply(
168
+ this.events[this._i].callbackContext,
169
+ this.events[this._i].args
170
+ );
153
171
  }
154
172
  this._i += 1;
155
173
  } else {
@@ -272,5 +290,4 @@ export default class {
272
290
  }
273
291
  return 0;
274
292
  }
275
-
276
293
  }
@@ -1,11 +1,10 @@
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
6
 
7
7
  export default class {
8
-
9
8
  constructor(timer, delay, tick, repeatCount, loop, callback, callbackContext, args) {
10
9
  this.timer = timer;
11
10
  this.delay = delay;
@@ -17,5 +16,4 @@ export default class {
17
16
  this.args = args;
18
17
  this.pendingDelete = false;
19
18
  }
20
-
21
19
  }
@@ -1,15 +1,14 @@
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 TweenData from './tween_data';
6
+ import { Signal } from './signal';
7
+ import { TweenData } from './tween_data';
8
8
  import * as MathUtils from '../util/math';
9
9
  import { TWEEN_PENDING, TWEEN_RUNNING, TWEEN_COMPLETE, TWEEN_LOOPED } from './const';
10
10
 
11
- export default class {
12
-
11
+ export class Tween {
13
12
  constructor(target, game, manager) {
14
13
  this.game = game;
15
14
  this.target = target;
@@ -36,7 +35,15 @@ export default class {
36
35
  this._hasStarted = false;
37
36
  }
38
37
 
39
- to(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
38
+ to(
39
+ properties,
40
+ duration = 1000,
41
+ ease = 'Linear',
42
+ autoStart = false,
43
+ delay = 0,
44
+ repeat = 0,
45
+ yoyo = false
46
+ ) {
40
47
  if (typeof ease === 'string' && this.manager.easeMap[ease]) {
41
48
  ease = this.manager.easeMap[ease];
42
49
  }
@@ -50,7 +57,15 @@ export default class {
50
57
  return this;
51
58
  }
52
59
 
53
- from(properties, duration = 1000, ease = 'Linear', autoStart = false, delay = 0, repeat = 0, yoyo = false) {
60
+ from(
61
+ properties,
62
+ duration = 1000,
63
+ ease = 'Linear',
64
+ autoStart = false,
65
+ delay = 0,
66
+ repeat = 0,
67
+ yoyo = false
68
+ ) {
54
69
  if (typeof ease === 'string' && this.manager.easeMap[ease]) {
55
70
  ease = this.manager.easeMap[ease];
56
71
  }
@@ -66,7 +81,12 @@ export default class {
66
81
  }
67
82
 
68
83
  start(index = 0) {
69
- if (this.game === null || this.target === null || this.timeline.length === 0 || this.isRunning) {
84
+ if (
85
+ this.game === null ||
86
+ this.target === null ||
87
+ this.timeline.length === 0 ||
88
+ this.isRunning
89
+ ) {
70
90
  return this;
71
91
  }
72
92
  // Populate the tween data
@@ -177,7 +197,7 @@ export default class {
177
197
  }
178
198
 
179
199
  loop(value = true) {
180
- this.repeatCounter = (value) ? -1 : 0;
200
+ this.repeatCounter = value ? -1 : 0;
181
201
  return this;
182
202
  }
183
203
 
@@ -206,7 +226,7 @@ export default class {
206
226
  this._codePaused = false;
207
227
  for (let i = 0; i < this.timeline.length; i += 1) {
208
228
  if (!this.timeline[i].isRunning) {
209
- this.timeline[i].startTime += (this.game.time.time - this._pausedTime);
229
+ this.timeline[i].startTime += this.game.time.time - this._pausedTime;
210
230
  }
211
231
  }
212
232
  }
@@ -234,7 +254,12 @@ export default class {
234
254
  this._hasStarted = true;
235
255
  }
236
256
  if (this._onUpdateCallback !== null) {
237
- this._onUpdateCallback.call(this._onUpdateCallbackContext, this, this.timeline[this.current].value, this.timeline[this.current]);
257
+ this._onUpdateCallback.call(
258
+ this._onUpdateCallbackContext,
259
+ this,
260
+ this.timeline[this.current].value,
261
+ this.timeline[this.current]
262
+ );
238
263
  }
239
264
  // In case the update callback modifies this tween
240
265
  return this.isRunning;
@@ -324,5 +349,4 @@ export default class {
324
349
  }
325
350
  return total;
326
351
  }
327
-
328
352
  }
@@ -1,13 +1,12 @@
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
6
  import * as MathUtils from '../util/math';
7
7
  import { TWEEN_PENDING, TWEEN_RUNNING, TWEEN_COMPLETE, TWEEN_LOOPED } from './const';
8
8
 
9
- export default class {
10
-
9
+ export class TweenData {
11
10
  constructor(parent) {
12
11
  this.parent = parent;
13
12
  this.game = parent.game;
@@ -145,12 +144,19 @@ export default class {
145
144
  const start = this.vStart[property];
146
145
  const end = this.vEnd[property];
147
146
  if (Array.isArray(end)) {
148
- this.parent.target[property] = this.interpolationFunction.call(this.interpolationContext, end, this.value);
147
+ this.parent.target[property] = this.interpolationFunction.call(
148
+ this.interpolationContext,
149
+ end,
150
+ this.value
151
+ );
149
152
  } else {
150
- this.parent.target[property] = start + ((end - start) * this.value);
153
+ this.parent.target[property] = start + (end - start) * this.value;
151
154
  }
152
155
  }
153
- if ((!this.parent.reverse && this.percent === 1) || (this.parent.reverse && this.percent === 0)) {
156
+ if (
157
+ (!this.parent.reverse && this.percent === 1) ||
158
+ (this.parent.reverse && this.percent === 0)
159
+ ) {
154
160
  return this.repeat();
155
161
  }
156
162
  return TWEEN_RUNNING;
@@ -184,11 +190,14 @@ export default class {
184
190
  if (Array.isArray(end)) {
185
191
  blob[property] = this.interpolationFunction(end, this.value);
186
192
  } else {
187
- blob[property] = start + ((end - start) * this.value);
193
+ blob[property] = start + (end - start) * this.value;
188
194
  }
189
195
  }
190
196
  data.push(blob);
191
- if ((!this.parent.reverse && this.percent === 1) || (this.parent.reverse && this.percent === 0)) {
197
+ if (
198
+ (!this.parent.reverse && this.percent === 1) ||
199
+ (this.parent.reverse && this.percent === 0)
200
+ ) {
192
201
  complete = true;
193
202
  }
194
203
  } while (!complete);
@@ -254,5 +263,4 @@ export default class {
254
263
  }
255
264
  return TWEEN_LOOPED;
256
265
  }
257
-
258
266
  }