@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,22 @@
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 DOM from './dom';
8
- import Point from '../geom/point';
9
- import Rectangle from '../geom/rectangle';
10
- import { SCALE_OFF, SCALE_RESIZE, SCALE_EXACT_FIT, SCALE_USER, SCALE_SHOW_ALL, RENDER_CANVAS } from './const';
11
-
12
- export default class {
13
-
8
+ import { Point } from '../geom/point';
9
+ import { Rectangle } from '../geom/rectangle';
10
+ import {
11
+ SCALE_OFF,
12
+ SCALE_RESIZE,
13
+ SCALE_EXACT_FIT,
14
+ SCALE_USER,
15
+ SCALE_SHOW_ALL,
16
+ RENDER_CANVAS,
17
+ } from './const';
18
+
19
+ export class ScaleManager {
14
20
  constructor(game, width, height) {
15
21
  this.game = game;
16
22
  this.dom = new DOM(game.device);
@@ -102,14 +108,14 @@ export default class {
102
108
  }
103
109
  // Configure event listeners
104
110
  const scope = this;
105
- this._orientationChange = event => scope.orientationChange(event);
106
- this._windowResize = event => scope.windowResize(event);
111
+ this._orientationChange = (event) => scope.orientationChange(event);
112
+ this._windowResize = (event) => scope.windowResize(event);
107
113
  // This does not appear to be on the standards track
108
114
  window.addEventListener('orientationchange', this._orientationChange, false);
109
115
  window.addEventListener('resize', this._windowResize, false);
110
116
  if (this.compatibility.supportsFullScreen) {
111
- this._fullScreenChange = event => scope.fullScreenChange(event);
112
- this._fullScreenError = event => scope.fullScreenError(event);
117
+ this._fullScreenChange = (event) => scope.fullScreenChange(event);
118
+ this._fullScreenError = (event) => scope.fullScreenError(event);
113
119
  document.addEventListener('webkitfullscreenchange', this._fullScreenChange, false);
114
120
  document.addEventListener('mozfullscreenchange', this._fullScreenChange, false);
115
121
  document.addEventListener('MSFullscreenChange', this._fullScreenChange, false);
@@ -225,7 +231,12 @@ export default class {
225
231
  }
226
232
 
227
233
  signalSizeChange() {
228
- if (this.width !== this._lastReportedCanvasSize.width || this.height !== this._lastReportedCanvasSize.height || this.game.width !== this._lastReportedGameSize.width || this.game.height !== this._lastReportedGameSize.height) {
234
+ if (
235
+ this.width !== this._lastReportedCanvasSize.width ||
236
+ this.height !== this._lastReportedCanvasSize.height ||
237
+ this.game.width !== this._lastReportedGameSize.width ||
238
+ this.game.height !== this._lastReportedGameSize.height
239
+ ) {
229
240
  const width = this.width;
230
241
  const height = this.height;
231
242
  this._lastReportedCanvasSize.setTo(0, 0, width, height);
@@ -251,7 +262,7 @@ export default class {
251
262
  }
252
263
 
253
264
  preUpdate() {
254
- if (this.game.time.time < (this._lastUpdate + this._updateThrottle)) {
265
+ if (this.game.time.time < this._lastUpdate + this._updateThrottle) {
255
266
  return;
256
267
  }
257
268
  const prevThrottle = this._updateThrottle;
@@ -335,7 +346,8 @@ export default class {
335
346
  const previousOrientation = this.screenOrientation;
336
347
  const previouslyIncorrect = this.incorrectOrientation;
337
348
  this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback);
338
- this.incorrectOrientation = (this.forceLandscape && !this.isLandscape) || (this.forcePortrait && !this.isPortrait);
349
+ this.incorrectOrientation =
350
+ (this.forceLandscape && !this.isLandscape) || (this.forcePortrait && !this.isPortrait);
339
351
  const changed = previousOrientation !== this.screenOrientation;
340
352
  const correctnessChanged = previouslyIncorrect !== this.incorrectOrientation;
341
353
  if (correctnessChanged) {
@@ -390,10 +402,13 @@ export default class {
390
402
  this.width = this.game.width;
391
403
  this.height = this.game.height;
392
404
  } else if (scaleMode === SCALE_USER) {
393
- this.width = (this.game.width * this._userScaleFactor.x) - this._userScaleTrim.x;
394
- this.height = (this.game.height * this._userScaleFactor.y) - this._userScaleTrim.y;
405
+ this.width = this.game.width * this._userScaleFactor.x - this._userScaleTrim.x;
406
+ this.height = this.game.height * this._userScaleFactor.y - this._userScaleTrim.y;
395
407
  }
396
- if (!this.compatibility.canExpandParent && (scaleMode === SCALE_SHOW_ALL || scaleMode === SCALE_USER)) {
408
+ if (
409
+ !this.compatibility.canExpandParent &&
410
+ (scaleMode === SCALE_SHOW_ALL || scaleMode === SCALE_USER)
411
+ ) {
397
412
  const bounds = this.getParentBounds(this._tempBounds);
398
413
  this.width = Math.min(this.width, bounds.width);
399
414
  this.height = Math.min(this.height, bounds.height);
@@ -414,8 +429,15 @@ export default class {
414
429
  } else {
415
430
  // Ref. http://msdn.microsoft.com/en-us/library/hh781509(v=vs.85).aspx for getBoundingClientRect
416
431
  const clientRect = parentNode.getBoundingClientRect();
417
- const parentRect = (parentNode.offsetParent) ? parentNode.offsetParent.getBoundingClientRect() : parentNode.getBoundingClientRect();
418
- bounds.setTo(clientRect.left - parentRect.left, clientRect.top - parentRect.top, clientRect.width, clientRect.height);
432
+ const parentRect = parentNode.offsetParent
433
+ ? parentNode.offsetParent.getBoundingClientRect()
434
+ : parentNode.getBoundingClientRect();
435
+ bounds.setTo(
436
+ clientRect.left - parentRect.left,
437
+ clientRect.top - parentRect.top,
438
+ clientRect.width,
439
+ clientRect.height
440
+ );
419
441
  const wc = this.windowConstraints;
420
442
  if (wc.right) {
421
443
  const windowBounds = wc.right === 'layout' ? layoutBounds : visualBounds;
@@ -426,7 +448,12 @@ export default class {
426
448
  bounds.bottom = Math.min(bounds.bottom, windowBounds.height);
427
449
  }
428
450
  }
429
- bounds.setTo(Math.round(bounds.x), Math.round(bounds.y), Math.round(bounds.width), Math.round(bounds.height));
451
+ bounds.setTo(
452
+ Math.round(bounds.x),
453
+ Math.round(bounds.y),
454
+ Math.round(bounds.width),
455
+ Math.round(bounds.height)
456
+ );
430
457
  return bounds;
431
458
  }
432
459
 
@@ -440,7 +467,7 @@ export default class {
440
467
  const canvasBounds = canvas.getBoundingClientRect();
441
468
  if (this.width < parentBounds.width && !this.incorrectOrientation) {
442
469
  const currentEdge = canvasBounds.left - parentBounds.x;
443
- let targetEdge = (parentBounds.width / 2) - (this.width / 2);
470
+ let targetEdge = parentBounds.width / 2 - this.width / 2;
444
471
  targetEdge = Math.max(targetEdge, 0);
445
472
  const offset = targetEdge - currentEdge;
446
473
  margin.left = Math.round(offset);
@@ -457,7 +484,7 @@ export default class {
457
484
  const canvasBounds = canvas.getBoundingClientRect();
458
485
  if (this.height < parentBounds.height && !this.incorrectOrientation) {
459
486
  const currentEdge = canvasBounds.top - parentBounds.y;
460
- let targetEdge = (parentBounds.height / 2) - (this.height / 2);
487
+ let targetEdge = parentBounds.height / 2 - this.height / 2;
461
488
  targetEdge = Math.max(targetEdge, 0);
462
489
  const offset = targetEdge - currentEdge;
463
490
  margin.top = Math.round(offset);
@@ -482,7 +509,10 @@ export default class {
482
509
  reflowCanvas() {
483
510
  if (!this.incorrectOrientation) {
484
511
  this.width = Math.max(this.minWidth || 0, Math.min(this.maxWidth || this.width, this.width));
485
- this.height = Math.max(this.minHeight || 0, Math.min(this.maxHeight || this.height, this.height));
512
+ this.height = Math.max(
513
+ this.minHeight || 0,
514
+ Math.min(this.maxHeight || this.height, this.height)
515
+ );
486
516
  }
487
517
  this.resetCanvas();
488
518
  if (!this.compatibility.noMargins) {
@@ -530,9 +560,9 @@ export default class {
530
560
  const height = bounds.height;
531
561
  let multiplier;
532
562
  if (expanding) {
533
- multiplier = Math.max((height / this.game.height), (width / this.game.width));
563
+ multiplier = Math.max(height / this.game.height, width / this.game.width);
534
564
  } else {
535
- multiplier = Math.min((height / this.game.height), (width / this.game.width));
565
+ multiplier = Math.min(height / this.game.height, width / this.game.width);
536
566
  }
537
567
  this.width = Math.round(this.game.width * multiplier);
538
568
  this.height = Math.round(this.game.height * multiplier);
@@ -576,8 +606,15 @@ export default class {
576
606
  }
577
607
  if (this.compatibility.clickTrampoline === 'when-not-mouse') {
578
608
  const input = this.game.input;
579
- if (input.activePointer && input.activePointer !== input.mousePointer && (allowTrampoline || allowTrampoline !== false)) {
580
- input.activePointer.addClickTrampoline('startFullScreen', this.startFullScreen, this, [antialias, false]);
609
+ if (
610
+ input.activePointer &&
611
+ input.activePointer !== input.mousePointer &&
612
+ (allowTrampoline || allowTrampoline !== false)
613
+ ) {
614
+ input.activePointer.addClickTrampoline('startFullScreen', this.startFullScreen, this, [
615
+ antialias,
616
+ false,
617
+ ]);
581
618
  return false;
582
619
  }
583
620
  }
@@ -698,7 +735,10 @@ export default class {
698
735
  }
699
736
 
700
737
  get boundingParent() {
701
- if (this.parentIsWindow || (this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget)) {
738
+ if (
739
+ this.parentIsWindow ||
740
+ (this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget)
741
+ ) {
702
742
  return null;
703
743
  }
704
744
  const parentNode = this.game.canvas && this.game.canvas.parentNode;
@@ -752,7 +792,12 @@ export default class {
752
792
  }
753
793
 
754
794
  get isFullScreen() {
755
- return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
795
+ return !!(
796
+ document.fullscreenElement ||
797
+ document.webkitFullscreenElement ||
798
+ document.mozFullScreenElement ||
799
+ document.msFullscreenElement
800
+ );
756
801
  }
757
802
 
758
803
  get isPortrait() {
@@ -770,5 +815,4 @@ export default class {
770
815
  get isGameLandscape() {
771
816
  return this.width > this.height;
772
817
  }
773
-
774
818
  }
@@ -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 Scene {
8
7
  constructor() {
9
8
  this.game = null;
10
9
  this.key = '';
@@ -37,5 +36,4 @@ export default class {
37
36
  shutdown() {
38
37
  // inherit
39
38
  }
40
-
41
39
  }
@@ -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 Scene from './scene';
7
-
8
- export default class {
6
+ import { Scene } from './scene';
9
7
 
8
+ export class SceneManager {
10
9
  constructor(game, pendingState) {
11
10
  this.game = game;
12
11
  this.states = {};
@@ -141,7 +140,12 @@ export default class {
141
140
 
142
141
  checkState(key) {
143
142
  if (this.states[key]) {
144
- if (this.states[key].preload || this.states[key].create || this.states[key].update || this.states[key].render) {
143
+ if (
144
+ this.states[key].preload ||
145
+ this.states[key].create ||
146
+ this.states[key].update ||
147
+ this.states[key].render
148
+ ) {
145
149
  return true;
146
150
  }
147
151
  return false;
@@ -235,5 +239,4 @@ export default class {
235
239
  get created() {
236
240
  return this._created;
237
241
  }
238
-
239
242
  }
@@ -1,12 +1,12 @@
1
1
  /**
2
+ * @module core/signal
3
+ * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
2
4
  * @author Andras Csizmadia <andras@vpmedia.hu>
3
5
  * @author Richard Davey <rich@photonstorm.com>
4
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
5
6
  */
6
- import SignalBinding from './signal_binding';
7
-
8
- export default class {
7
+ import { SignalBinding } from './signal_binding';
9
8
 
9
+ export class Signal {
10
10
  constructor() {
11
11
  this._bindings = null;
12
12
  this._prevParams = null;
@@ -18,7 +18,12 @@ export default class {
18
18
 
19
19
  validateListener(listener, fnName) {
20
20
  if (typeof listener !== 'function') {
21
- throw new Error('Signal: listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName));
21
+ throw new Error(
22
+ 'Signal: listener is a required param of {fn}() and should be a Function.'.replace(
23
+ '{fn}',
24
+ fnName
25
+ )
26
+ );
22
27
  }
23
28
  }
24
29
 
@@ -28,7 +33,13 @@ export default class {
28
33
  if (prevIndex !== -1) {
29
34
  binding = this._bindings[prevIndex];
30
35
  if (binding.isOnce() !== isOnce) {
31
- throw new Error('You cannot add' + (isOnce ? '' : 'Once') + '() then add' + (!isOnce ? '' : 'Once') + '() the same listener without removing the relationship first.');
36
+ throw new Error(
37
+ 'You cannot add' +
38
+ (isOnce ? '' : 'Once') +
39
+ '() then add' +
40
+ (!isOnce ? '' : 'Once') +
41
+ '() the same listener without removing the relationship first.'
42
+ );
32
43
  }
33
44
  } else {
34
45
  binding = new SignalBinding(this, listener, isOnce, listenerContext, priority, args);
@@ -48,8 +59,7 @@ export default class {
48
59
  let n = this._bindings.length;
49
60
  do {
50
61
  n -= 1;
51
- }
52
- while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
62
+ } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
53
63
  this._bindings.splice(n + 1, 0, binding);
54
64
  }
55
65
 
@@ -144,8 +154,7 @@ export default class {
144
154
  // reverse loop since listeners with higher priority will be added at the end of the list
145
155
  do {
146
156
  n -= 1;
147
- }
148
- while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
157
+ } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
149
158
  }
150
159
 
151
160
  forget() {
@@ -171,5 +180,4 @@ export default class {
171
180
  }
172
181
  return this._boundDispatch;
173
182
  }
174
-
175
183
  }
@@ -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
- export default class {
8
-
7
+ export class SignalBinding {
9
8
  constructor(signal, listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
10
9
  this._signal = signal;
11
10
  this._listener = listener;
@@ -33,7 +32,6 @@ export default class {
33
32
  }
34
33
  }
35
34
  return handlerReturn;
36
-
37
35
  }
38
36
 
39
37
  detach() {
@@ -41,7 +39,7 @@ export default class {
41
39
  }
42
40
 
43
41
  isBound() {
44
- return (!!this._signal && !!this._listener);
42
+ return !!this._signal && !!this._listener;
45
43
  }
46
44
 
47
45
  isOnce() {
@@ -63,7 +61,14 @@ export default class {
63
61
  }
64
62
 
65
63
  toString() {
66
- return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']';
64
+ return (
65
+ '[SignalBinding isOnce:' +
66
+ this._isOnce +
67
+ ', isBound:' +
68
+ this.isBound() +
69
+ ', active:' +
70
+ this.active +
71
+ ']'
72
+ );
67
73
  }
68
-
69
74
  }
@@ -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 Signal from './signal';
7
-
8
- export default class {
6
+ import { Signal } from './signal';
9
7
 
8
+ export class Sound {
10
9
  constructor(game, key, volume = 1, loop = false, connect = null) {
11
10
  // TODO
12
11
  // https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
@@ -179,8 +178,12 @@ export default class {
179
178
  }
180
179
 
181
180
  play(marker, position, volume, loop, forceRestart) {
182
- if (marker === undefined || marker === false || marker === null) { marker = ''; }
183
- if (forceRestart === undefined) { forceRestart = true; }
181
+ if (marker === undefined || marker === false || marker === null) {
182
+ marker = '';
183
+ }
184
+ if (forceRestart === undefined) {
185
+ forceRestart = true;
186
+ }
184
187
 
185
188
  if (this.isPlaying && !this.allowMultiple && !forceRestart && !this.override) {
186
189
  // Use Restart instead
@@ -231,8 +234,12 @@ export default class {
231
234
  }
232
235
  } else {
233
236
  position = position || 0;
234
- if (volume === undefined) { volume = this._volume; }
235
- if (loop === undefined) { loop = this.loop; }
237
+ if (volume === undefined) {
238
+ volume = this._volume;
239
+ }
240
+ if (loop === undefined) {
241
+ loop = this.loop;
242
+ }
236
243
  this.position = Math.max(0, position);
237
244
  this.volume = volume;
238
245
  this.loop = loop;
@@ -280,7 +287,10 @@ export default class {
280
287
  this.onPlay.dispatch(this);
281
288
  } else {
282
289
  this.pendingPlayback = true;
283
- if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding === false) {
290
+ if (
291
+ this.game.cache.getSound(this.key) &&
292
+ this.game.cache.getSound(this.key).isDecoding === false
293
+ ) {
284
294
  this.game.sound.decode(this.key, this);
285
295
  }
286
296
  }
@@ -331,7 +341,7 @@ export default class {
331
341
  resume() {
332
342
  if (this.paused && this._sound) {
333
343
  if (!this.game.sound.noAudio) {
334
- const p = Math.max(0, this.position + (this.pausedPosition / 1000));
344
+ const p = Math.max(0, this.position + this.pausedPosition / 1000);
335
345
  this._sound = this.context.createBufferSource();
336
346
  this._sound.buffer = this._buffer;
337
347
  if (this.externalNode) {
@@ -345,7 +355,7 @@ export default class {
345
355
  if (!this.loop && this.currentMarker === '') {
346
356
  this._sound.onended = this.onEndedHandler.bind(this);
347
357
  }
348
- const duration = this.duration - (this.pausedPosition / 1000);
358
+ const duration = this.duration - this.pausedPosition / 1000;
349
359
  if (this._sound.start === undefined) {
350
360
  this._sound.noteGrainOn(0, p, duration);
351
361
  // https://bugs.chromium.org/p/chromium/issues/detail?id=457099
@@ -357,7 +367,7 @@ export default class {
357
367
  }
358
368
  this.isPlaying = true;
359
369
  this.paused = false;
360
- this.startTime += (this.game.time.time - this.pausedTime);
370
+ this.startTime += this.game.time.time - this.pausedTime;
361
371
  this.onResume.dispatch(this);
362
372
  }
363
373
  }
@@ -441,7 +451,7 @@ export default class {
441
451
  }
442
452
 
443
453
  get mute() {
444
- return (this._muted || this.game.sound.mute);
454
+ return this._muted || this.game.sound.mute;
445
455
  }
446
456
 
447
457
  set mute(value) {
@@ -479,5 +489,4 @@ export default class {
479
489
  this.gainNode.gain.value = value;
480
490
  }
481
491
  }
482
-
483
492
  }
@@ -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 ArraySet from './array_set';
7
- import Signal from './signal';
8
- import Sound from './sound';
9
- import SoundSprite from './sound_sprite';
10
-
11
- export default class {
6
+ import { ArraySet } from './array_set';
7
+ import { Signal } from './signal';
8
+ import { Sound } from './sound';
9
+ import { SoundSprite } from './sound_sprite';
12
10
 
11
+ export class SoundManager {
13
12
  constructor(game) {
14
13
  this.game = game;
15
14
  this.onChange = new Signal();
@@ -56,11 +55,16 @@ export default class {
56
55
  this.game.exceptionHandler(e);
57
56
  }
58
57
  }
59
- if (this.context === null || (this.context && this.context.createGain === undefined && this.context.createGainNode === undefined)) {
58
+ if (
59
+ this.context === null ||
60
+ (this.context &&
61
+ this.context.createGain === undefined &&
62
+ this.context.createGainNode === undefined)
63
+ ) {
60
64
  this.noAudio = true;
61
65
  return;
62
- }
63
- this.baseLatency = this.context.baseLatency || (256 / (this.context.sampleRate || 44100));
66
+ }
67
+ this.baseLatency = this.context.baseLatency || 256 / (this.context.sampleRate || 44100);
64
68
  if (this.context.createGain === undefined) {
65
69
  this.masterGain = this.context.createGainNode();
66
70
  } else {
@@ -75,18 +79,27 @@ export default class {
75
79
  this.addUnlockHandlers();
76
80
  }
77
81
  this.context.addEventListener('statechange', () => {
78
- this.onChange.dispatch('onContextStateChange', { state: this.context.state, isLocked: this.isLocked });
79
- if (!this.isLocked && (this.context.state === 'suspended' || this.context.state === 'interrupted')) {
82
+ this.onChange.dispatch('onContextStateChange', {
83
+ state: this.context.state,
84
+ isLocked: this.isLocked,
85
+ });
86
+ if (
87
+ !this.isLocked &&
88
+ (this.context.state === 'suspended' || this.context.state === 'interrupted')
89
+ ) {
80
90
  this.addUnlockHandlers();
81
91
  } else if (this.isLocked && this.context.state === 'running') {
82
92
  this.removeUnlockHandlers();
83
- }
93
+ }
84
94
  });
85
95
  }
86
96
 
87
97
  addUnlockHandlers() {
88
98
  this.isLocked = true;
89
- this.onChange.dispatch('addUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
99
+ this.onChange.dispatch('addUnlockHandlers', {
100
+ state: this.context.state,
101
+ isLocked: this.isLocked,
102
+ });
90
103
  document.body.addEventListener('touchstart', this.onUnlockEventBinded, false);
91
104
  document.body.addEventListener('touchend', this.onUnlockEventBinded, false);
92
105
  document.body.addEventListener('click', this.onUnlockEventBinded, false);
@@ -95,7 +108,10 @@ export default class {
95
108
 
96
109
  removeUnlockHandlers() {
97
110
  this.isLocked = false;
98
- this.onChange.dispatch('removeUnlockHandlers', { state: this.context.state, isLocked: this.isLocked });
111
+ this.onChange.dispatch('removeUnlockHandlers', {
112
+ state: this.context.state,
113
+ isLocked: this.isLocked,
114
+ });
99
115
  document.body.removeEventListener('touchstart', this.onUnlockEventBinded);
100
116
  document.body.removeEventListener('touchend', this.onUnlockEventBinded);
101
117
  document.body.removeEventListener('click', this.onUnlockEventBinded);
@@ -105,19 +121,39 @@ export default class {
105
121
  onUnlockEvent(event) {
106
122
  const initialState = this.context.state;
107
123
  if (initialState !== 'suspended' && initialState !== 'interrupted') {
108
- this.onChange.dispatch('onUnlockResumeDenied', { state: initialState, isLocked: this.isLocked, event });
124
+ this.onChange.dispatch('onUnlockResumeDenied', {
125
+ state: initialState,
126
+ isLocked: this.isLocked,
127
+ event,
128
+ });
109
129
  this.removeUnlockHandlers();
110
130
  return;
111
131
  }
112
- this.onChange.dispatch('onContextResumeStart', { state: initialState, isLocked: this.isLocked, event });
113
- this.context.resume().then(() => {
114
- this.onChange.dispatch('onContextResumeResult', { initialState, state: this.context.state, isLocked: this.isLocked });
115
- this.removeUnlockHandlers();
116
- }).catch((e) => {
117
- this.onChange.dispatch('onContextResumeReject', { initialState, state: this.context.state, isLocked: this.isLocked, error: e });
118
- this.removeUnlockHandlers();
119
- this.game.exceptionHandler(e, { initialState, state: this.context.state });
132
+ this.onChange.dispatch('onContextResumeStart', {
133
+ state: initialState,
134
+ isLocked: this.isLocked,
135
+ event,
120
136
  });
137
+ this.context
138
+ .resume()
139
+ .then(() => {
140
+ this.onChange.dispatch('onContextResumeResult', {
141
+ initialState,
142
+ state: this.context.state,
143
+ isLocked: this.isLocked,
144
+ });
145
+ this.removeUnlockHandlers();
146
+ })
147
+ .catch((e) => {
148
+ this.onChange.dispatch('onContextResumeReject', {
149
+ initialState,
150
+ state: this.context.state,
151
+ isLocked: this.isLocked,
152
+ error: e,
153
+ });
154
+ this.removeUnlockHandlers();
155
+ this.game.exceptionHandler(e, { initialState, state: this.context.state });
156
+ });
121
157
  }
122
158
 
123
159
  stopAll() {
@@ -158,7 +194,8 @@ export default class {
158
194
  if (soundData) {
159
195
  if (this.game.cache.isSoundDecoded(key) === false) {
160
196
  this.game.cache.updateSound(key, 'isDecoding', true);
161
- this.context.decodeAudioData(soundData)
197
+ this.context
198
+ .decodeAudioData(soundData)
162
199
  .then((buffer) => {
163
200
  this.game.cache.decodedSound(key, buffer);
164
201
  })
@@ -340,5 +377,4 @@ export default class {
340
377
  }
341
378
  }
342
379
  }
343
-
344
380
  }