@vpmedia/phaser 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/README.md +3 -3
  2. package/package.json +6 -5
  3. package/src/index.js +15 -18
  4. package/src/phaser/core/animation.js +102 -6
  5. package/src/phaser/core/animation_manager.js +88 -10
  6. package/src/phaser/core/animation_parser.js +5 -18
  7. package/src/phaser/core/array_set.js +51 -5
  8. package/src/phaser/core/cache.js +291 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +3 -6
  11. package/src/phaser/core/device_util.js +3 -16
  12. package/src/phaser/core/dom.js +127 -29
  13. package/src/phaser/core/event_manager.js +128 -6
  14. package/src/phaser/core/factory.js +69 -34
  15. package/src/phaser/core/frame.js +43 -6
  16. package/src/phaser/core/frame_data.js +55 -5
  17. package/src/phaser/core/frame_util.js +7 -12
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +116 -17
  20. package/src/phaser/core/input_handler.js +242 -42
  21. package/src/phaser/core/input_mouse.js +66 -5
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +79 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +274 -101
  26. package/src/phaser/core/loader_parser.js +2 -10
  27. package/src/phaser/core/raf.js +16 -5
  28. package/src/phaser/core/scale_manager.js +204 -39
  29. package/src/phaser/core/scene.js +24 -5
  30. package/src/phaser/core/scene_manager.js +81 -11
  31. package/src/phaser/core/signal.js +88 -11
  32. package/src/phaser/core/signal_binding.js +35 -15
  33. package/src/phaser/core/sound.js +99 -10
  34. package/src/phaser/core/sound_manager.js +89 -13
  35. package/src/phaser/core/sound_sprite.js +20 -5
  36. package/src/phaser/core/stage.js +43 -7
  37. package/src/phaser/core/time.js +67 -5
  38. package/src/phaser/core/timer.js +107 -30
  39. package/src/phaser/core/timer_event.js +11 -6
  40. package/src/phaser/core/tween.js +124 -30
  41. package/src/phaser/core/tween_data.js +42 -18
  42. package/src/phaser/core/tween_easing.js +1 -8
  43. package/src/phaser/core/tween_manager.js +47 -5
  44. package/src/phaser/core/world.js +9 -6
  45. package/src/phaser/display/bitmap_text.js +91 -10
  46. package/src/phaser/display/button.js +63 -12
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -13
  49. package/src/phaser/display/canvas/masker.js +0 -6
  50. package/src/phaser/display/canvas/pool.js +0 -7
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -43
  53. package/src/phaser/display/canvas/util.js +0 -6
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +161 -26
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -8
  58. package/src/phaser/display/group.js +74 -9
  59. package/src/phaser/display/image.js +85 -9
  60. package/src/phaser/display/sprite_batch.js +3 -8
  61. package/src/phaser/display/sprite_util.js +3 -23
  62. package/src/phaser/display/text.js +331 -31
  63. package/src/phaser/display/webgl/abstract_filter.js +8 -7
  64. package/src/phaser/display/webgl/base_texture.js +20 -12
  65. package/src/phaser/display/webgl/blend_manager.js +14 -7
  66. package/src/phaser/display/webgl/earcut.js +4 -23
  67. package/src/phaser/display/webgl/earcut_node.js +6 -7
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
  69. package/src/phaser/display/webgl/filter_manager.js +25 -7
  70. package/src/phaser/display/webgl/filter_texture.js +21 -22
  71. package/src/phaser/display/webgl/graphics.js +5 -28
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -6
  74. package/src/phaser/display/webgl/render_texture.js +33 -21
  75. package/src/phaser/display/webgl/renderer.js +38 -11
  76. package/src/phaser/display/webgl/shader/complex.js +10 -6
  77. package/src/phaser/display/webgl/shader/fast.js +10 -6
  78. package/src/phaser/display/webgl/shader/normal.js +23 -32
  79. package/src/phaser/display/webgl/shader/primitive.js +10 -6
  80. package/src/phaser/display/webgl/shader/strip.js +10 -6
  81. package/src/phaser/display/webgl/shader_manager.js +18 -6
  82. package/src/phaser/display/webgl/sprite_batch.js +41 -8
  83. package/src/phaser/display/webgl/stencil_manager.js +28 -6
  84. package/src/phaser/display/webgl/texture.js +28 -15
  85. package/src/phaser/display/webgl/texture_util.js +0 -6
  86. package/src/phaser/display/webgl/util.js +0 -7
  87. package/src/phaser/geom/circle.js +123 -18
  88. package/src/phaser/geom/ellipse.js +39 -18
  89. package/src/phaser/geom/line.js +148 -16
  90. package/src/phaser/geom/matrix.js +73 -6
  91. package/src/phaser/geom/point.js +152 -6
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -6
  94. package/src/phaser/geom/rounded_rectangle.js +10 -6
  95. package/src/phaser/geom/util/circle.js +3 -9
  96. package/src/phaser/geom/util/ellipse.js +0 -7
  97. package/src/phaser/geom/util/line.js +5 -14
  98. package/src/phaser/geom/util/matrix.js +1 -7
  99. package/src/phaser/geom/util/point.js +0 -6
  100. package/src/phaser/geom/util/polygon.js +1 -7
  101. package/src/phaser/geom/util/rectangle.js +1 -7
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -7
  103. package/src/phaser/util/math.js +3 -21
  104. package/types/index.d.ts +2 -1
  105. package/types/index.d.ts.map +1 -1
  106. package/types/phaser/core/animation.d.ts +105 -4
  107. package/types/phaser/core/animation.d.ts.map +1 -1
  108. package/types/phaser/core/animation_manager.d.ts +87 -0
  109. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  110. package/types/phaser/core/animation_parser.d.ts +5 -4
  111. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  112. package/types/phaser/core/array_set.d.ts +53 -7
  113. package/types/phaser/core/array_set.d.ts.map +1 -1
  114. package/types/phaser/core/cache.d.ts +346 -56
  115. package/types/phaser/core/cache.d.ts.map +1 -1
  116. package/types/phaser/core/const.d.ts +143 -40
  117. package/types/phaser/core/const.d.ts.map +1 -1
  118. package/types/phaser/core/device.d.ts +0 -5
  119. package/types/phaser/core/device.d.ts.map +1 -1
  120. package/types/phaser/core/device_util.d.ts +1 -1
  121. package/types/phaser/core/device_util.d.ts.map +1 -1
  122. package/types/phaser/core/dom.d.ts +119 -0
  123. package/types/phaser/core/dom.d.ts.map +1 -1
  124. package/types/phaser/core/event_manager.d.ts +127 -0
  125. package/types/phaser/core/event_manager.d.ts.map +1 -1
  126. package/types/phaser/core/factory.d.ts +74 -7
  127. package/types/phaser/core/factory.d.ts.map +1 -1
  128. package/types/phaser/core/frame.d.ts +64 -21
  129. package/types/phaser/core/frame.d.ts.map +1 -1
  130. package/types/phaser/core/frame_data.d.ts +61 -9
  131. package/types/phaser/core/frame_data.d.ts.map +1 -1
  132. package/types/phaser/core/frame_util.d.ts +10 -8
  133. package/types/phaser/core/frame_util.d.ts.map +1 -1
  134. package/types/phaser/core/game.d.ts +40 -6
  135. package/types/phaser/core/game.d.ts.map +1 -1
  136. package/types/phaser/core/input.d.ts +114 -3
  137. package/types/phaser/core/input.d.ts.map +1 -1
  138. package/types/phaser/core/input_handler.d.ts +257 -24
  139. package/types/phaser/core/input_handler.d.ts.map +1 -1
  140. package/types/phaser/core/input_mouse.d.ts +51 -4
  141. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  142. package/types/phaser/core/input_mspointer.d.ts +43 -9
  143. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  144. package/types/phaser/core/input_pointer.d.ts +78 -2
  145. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  146. package/types/phaser/core/input_touch.d.ts +45 -8
  147. package/types/phaser/core/input_touch.d.ts.map +1 -1
  148. package/types/phaser/core/loader.d.ts +264 -19
  149. package/types/phaser/core/loader.d.ts.map +1 -1
  150. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  151. package/types/phaser/core/raf.d.ts +17 -7
  152. package/types/phaser/core/raf.d.ts.map +1 -1
  153. package/types/phaser/core/scale_manager.d.ts +201 -6
  154. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  155. package/types/phaser/core/scene.d.ts +21 -5
  156. package/types/phaser/core/scene.d.ts.map +1 -1
  157. package/types/phaser/core/scene_manager.d.ts +90 -10
  158. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  159. package/types/phaser/core/signal.d.ts +93 -9
  160. package/types/phaser/core/signal.d.ts.map +1 -1
  161. package/types/phaser/core/signal_binding.d.ts +34 -5
  162. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  163. package/types/phaser/core/sound.d.ts +111 -14
  164. package/types/phaser/core/sound.d.ts.map +1 -1
  165. package/types/phaser/core/sound_manager.d.ts +93 -7
  166. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  167. package/types/phaser/core/sound_sprite.d.ts +22 -8
  168. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  169. package/types/phaser/core/stage.d.ts +32 -3
  170. package/types/phaser/core/stage.d.ts.map +1 -1
  171. package/types/phaser/core/time.d.ts +73 -6
  172. package/types/phaser/core/time.d.ts.map +1 -1
  173. package/types/phaser/core/timer.d.ts +103 -2
  174. package/types/phaser/core/timer.d.ts.map +1 -1
  175. package/types/phaser/core/timer_event.d.ts +11 -5
  176. package/types/phaser/core/timer_event.d.ts.map +1 -1
  177. package/types/phaser/core/tween.d.ts +122 -2
  178. package/types/phaser/core/tween.d.ts.map +1 -1
  179. package/types/phaser/core/tween_data.d.ts +41 -2
  180. package/types/phaser/core/tween_data.d.ts.map +1 -1
  181. package/types/phaser/core/tween_easing.d.ts +0 -5
  182. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  183. package/types/phaser/core/tween_manager.d.ts +49 -2
  184. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  185. package/types/phaser/core/world.d.ts +9 -1
  186. package/types/phaser/core/world.d.ts.map +1 -1
  187. package/types/phaser/display/bitmap_text.d.ts +84 -7
  188. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  189. package/types/phaser/display/button.d.ts +65 -8
  190. package/types/phaser/display/button.d.ts.map +1 -1
  191. package/types/phaser/display/canvas/buffer.d.ts +20 -4
  192. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  194. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/pool.d.ts +0 -6
  196. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/renderer.d.ts +29 -2
  198. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  200. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  201. package/types/phaser/display/display_object.d.ts +195 -8
  202. package/types/phaser/display/display_object.d.ts.map +1 -1
  203. package/types/phaser/display/graphics.d.ts +132 -6
  204. package/types/phaser/display/graphics.d.ts.map +1 -1
  205. package/types/phaser/display/graphics_data.d.ts +15 -1
  206. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  207. package/types/phaser/display/graphics_data_util.d.ts +3 -2
  208. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  209. package/types/phaser/display/group.d.ts +62 -0
  210. package/types/phaser/display/group.d.ts.map +1 -1
  211. package/types/phaser/display/image.d.ts +66 -2
  212. package/types/phaser/display/image.d.ts.map +1 -1
  213. package/types/phaser/display/sprite_batch.d.ts +4 -3
  214. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  215. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  216. package/types/phaser/display/text.d.ts +366 -46
  217. package/types/phaser/display/text.d.ts.map +1 -1
  218. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  219. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  220. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  221. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  222. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  223. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  224. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  226. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  228. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
  230. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  232. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  234. package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
  235. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  236. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/render_texture.d.ts +30 -3
  238. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/renderer.d.ts +41 -4
  240. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
  242. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
  244. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
  246. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
  248. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
  250. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
  252. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
  254. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  256. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/texture.d.ts +21 -0
  258. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  260. package/types/phaser/display/webgl/util.d.ts +0 -6
  261. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  262. package/types/phaser/geom/circle.d.ts +131 -9
  263. package/types/phaser/geom/circle.d.ts.map +1 -1
  264. package/types/phaser/geom/ellipse.d.ts +43 -5
  265. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  266. package/types/phaser/geom/line.d.ts +159 -13
  267. package/types/phaser/geom/line.d.ts.map +1 -1
  268. package/types/phaser/geom/matrix.d.ts +85 -11
  269. package/types/phaser/geom/matrix.d.ts.map +1 -1
  270. package/types/phaser/geom/point.d.ts +170 -18
  271. package/types/phaser/geom/point.d.ts.map +1 -1
  272. package/types/phaser/geom/polygon.d.ts +45 -5
  273. package/types/phaser/geom/polygon.d.ts.map +1 -1
  274. package/types/phaser/geom/rectangle.d.ts +253 -20
  275. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  276. package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
  277. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  278. package/types/phaser/geom/util/circle.d.ts +3 -3
  279. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  280. package/types/phaser/geom/util/ellipse.d.ts +0 -6
  281. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  282. package/types/phaser/geom/util/line.d.ts +5 -5
  283. package/types/phaser/geom/util/line.d.ts.map +1 -1
  284. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  285. package/types/phaser/geom/util/point.d.ts.map +1 -1
  286. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  287. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  288. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/util/math.d.ts +0 -5
  290. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,11 +1,15 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- */
6
- import { Signal } from './signal';
1
+ import { Game } from './game';
2
+ import { Signal } from './signal';
7
3
 
8
4
  export class Sound {
5
+ /**
6
+ * TBD.
7
+ * @param {Game} game - TBD.
8
+ * @param {string} key - TBD.
9
+ * @param volume - TBD.
10
+ * @param loop - TBD.
11
+ * @param connect - TBD.
12
+ */
9
13
  constructor(game, key, volume = 1, loop = false, connect = null) {
10
14
  // TODO
11
15
  // https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Migrating_from_webkitAudioContext
@@ -74,6 +78,10 @@ export class Sound {
74
78
  this._paused = false;
75
79
  }
76
80
 
81
+ /**
82
+ * TBD.
83
+ * @param {string} key - TBD.
84
+ */
77
85
  soundHasUnlocked(key) {
78
86
  if (key === this.key) {
79
87
  this._sound = this.game.cache.getSoundData(this.key);
@@ -81,6 +89,14 @@ export class Sound {
81
89
  }
82
90
  }
83
91
 
92
+ /**
93
+ * TBD.
94
+ * @param {string} name - TBD.
95
+ * @param {number} start - TBD.
96
+ * @param {number} duration - TBD.
97
+ * @param {number} volume - TBD.
98
+ * @param {boolean} loop - TBD.
99
+ */
84
100
  addMarker(name, start, duration = 1, volume = 1, loop = false) {
85
101
  this.markers[name] = {
86
102
  name,
@@ -93,10 +109,17 @@ export class Sound {
93
109
  };
94
110
  }
95
111
 
112
+ /**
113
+ * TBD.
114
+ * @param {string} name - TBD.
115
+ */
96
116
  removeMarker(name) {
97
117
  delete this.markers[name];
98
118
  }
99
119
 
120
+ /**
121
+ * TBD.
122
+ */
100
123
  onEndedHandler() {
101
124
  this._sound.onended = null;
102
125
  this.isPlaying = false;
@@ -126,6 +149,9 @@ export class Sound {
126
149
  }
127
150
  }
128
151
 
152
+ /**
153
+ * TBD.
154
+ */
129
155
  update() {
130
156
  if (!this.game.cache.checkSoundKey(this.key)) {
131
157
  this.destroy();
@@ -173,10 +199,24 @@ export class Sound {
173
199
  }
174
200
  }
175
201
 
202
+ /**
203
+ * TBD.
204
+ * @param {number} volume - TBD.
205
+ * @returns {Sound} TBD.
206
+ */
176
207
  loopFull(volume) {
177
208
  return this.play(null, 0, volume, true);
178
209
  }
179
210
 
211
+ /**
212
+ * TBD.
213
+ * @param {string} marker - TBD.
214
+ * @param {number} position - TBD.
215
+ * @param {number} volume - TBD.
216
+ * @param {boolean} loop - TBD.
217
+ * @param {boolean} forceRestart - TBD.
218
+ * @returns {Sound} TBD.
219
+ */
180
220
  play(marker, position, volume, loop, forceRestart) {
181
221
  if (marker === undefined || marker === false || marker === null) {
182
222
  marker = '';
@@ -287,10 +327,7 @@ export class Sound {
287
327
  this.onPlay.dispatch(this);
288
328
  } else {
289
329
  this.pendingPlayback = true;
290
- if (
291
- this.game.cache.getSound(this.key) &&
292
- this.game.cache.getSound(this.key).isDecoding === false
293
- ) {
330
+ if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding === false) {
294
331
  this.game.sound.decode(this.key, this);
295
332
  }
296
333
  }
@@ -323,10 +360,20 @@ export class Sound {
323
360
  return this;
324
361
  }
325
362
 
363
+ /**
364
+ * TBD.
365
+ * @param {string} marker - TBD.
366
+ * @param {number} position - TBD.
367
+ * @param {number} volume - TBD.
368
+ * @param {boolean} loop - TBD.
369
+ */
326
370
  restart(marker = '', position = 0, volume = 1, loop = false) {
327
371
  this.play(marker, position, volume, loop, true);
328
372
  }
329
373
 
374
+ /**
375
+ * TBD.
376
+ */
330
377
  pause() {
331
378
  if (this.isPlaying && this._sound) {
332
379
  this.paused = true;
@@ -338,6 +385,9 @@ export class Sound {
338
385
  }
339
386
  }
340
387
 
388
+ /**
389
+ * TBD.
390
+ */
341
391
  resume() {
342
392
  if (this.paused && this._sound) {
343
393
  if (!this.game.sound.noAudio) {
@@ -372,6 +422,9 @@ export class Sound {
372
422
  }
373
423
  }
374
424
 
425
+ /**
426
+ * TBD.
427
+ */
375
428
  stop() {
376
429
  if (this.isPlaying && this._sound) {
377
430
  if (!this.game.sound.noAudio) {
@@ -402,6 +455,12 @@ export class Sound {
402
455
  }
403
456
  }
404
457
 
458
+ /**
459
+ * TBD.
460
+ * @param {number} duration - TBD.
461
+ * @param {boolean} loop - TBD.
462
+ * @param {string} marker - TBD.
463
+ */
405
464
  fadeIn(duration, loop = false, marker = this.currentMarker) {
406
465
  if (this.paused) {
407
466
  return;
@@ -410,10 +469,19 @@ export class Sound {
410
469
  this.fadeTo(duration, 1);
411
470
  }
412
471
 
472
+ /**
473
+ * TBD.
474
+ * @param {number} duration - TBD.
475
+ */
413
476
  fadeOut(duration) {
414
477
  this.fadeTo(duration, 0);
415
478
  }
416
479
 
480
+ /**
481
+ * TBD.
482
+ * @param {number} duration - TBD.
483
+ * @param {number} volume - TBD.
484
+ */
417
485
  fadeTo(duration = 100, volume = 0) {
418
486
  if (!this.isPlaying || this.paused || volume === this.volume) {
419
487
  return;
@@ -422,6 +490,9 @@ export class Sound {
422
490
  this.fadeTween.onComplete.add(this.fadeComplete, this);
423
491
  }
424
492
 
493
+ /**
494
+ * TBD.
495
+ */
425
496
  fadeComplete() {
426
497
  this.onFadeComplete.dispatch(this, this.volume);
427
498
  if (this.volume === 0) {
@@ -429,6 +500,10 @@ export class Sound {
429
500
  }
430
501
  }
431
502
 
503
+ /**
504
+ * TBD.
505
+ * @param {boolean} remove - TBD.
506
+ */
432
507
  destroy(remove = true) {
433
508
  this._markedToDelete = true;
434
509
  this._removeFromSoundManager = remove;
@@ -450,10 +525,17 @@ export class Sound {
450
525
  }
451
526
  }
452
527
 
528
+ /**
529
+ * TBD.
530
+ * @returns {boolean} TBD.
531
+ */
453
532
  get mute() {
454
533
  return this._muted || this.game.sound.mute;
455
534
  }
456
535
 
536
+ /**
537
+ * TBD.
538
+ */
457
539
  set mute(value) {
458
540
  value = value || false;
459
541
  if (value === this._muted) {
@@ -474,10 +556,17 @@ export class Sound {
474
556
  this.onMute.dispatch(this);
475
557
  }
476
558
 
559
+ /**
560
+ * TBD.
561
+ * @returns {number} TBD.
562
+ */
477
563
  get volume() {
478
564
  return this._volume;
479
565
  }
480
566
 
567
+ /**
568
+ * TBD.
569
+ */
481
570
  set volume(value) {
482
571
  if (this._muted) {
483
572
  this._muteVolume = value;
@@ -1,14 +1,14 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- */
6
1
  import { ArraySet } from './array_set';
7
- import { Signal } from './signal';
2
+ import { Game } from './game';
3
+ import { Signal } from './signal';
8
4
  import { Sound } from './sound';
9
5
  import { SoundSprite } from './sound_sprite';
10
6
 
11
7
  export class SoundManager {
8
+ /**
9
+ * TBD.
10
+ * @param {Game} game - TBD.
11
+ */
12
12
  constructor(game) {
13
13
  this.game = game;
14
14
  this.onChange = new Signal();
@@ -29,6 +29,9 @@ export class SoundManager {
29
29
  this._watchContext = null;
30
30
  }
31
31
 
32
+ /**
33
+ * TBD.
34
+ */
32
35
  boot() {
33
36
  if (this.game.config.isForceDisabledAudio) {
34
37
  this.noAudio = true;
@@ -57,9 +60,7 @@ export class SoundManager {
57
60
  }
58
61
  if (
59
62
  this.context === null ||
60
- (this.context &&
61
- this.context.createGain === undefined &&
62
- this.context.createGainNode === undefined)
63
+ (this.context && this.context.createGain === undefined && this.context.createGainNode === undefined)
63
64
  ) {
64
65
  this.noAudio = true;
65
66
  return;
@@ -83,10 +84,7 @@ export class SoundManager {
83
84
  state: this.context.state,
84
85
  isLocked: this.isLocked,
85
86
  });
86
- if (
87
- !this.isLocked &&
88
- (this.context.state === 'suspended' || this.context.state === 'interrupted')
89
- ) {
87
+ if (!this.isLocked && (this.context.state === 'suspended' || this.context.state === 'interrupted')) {
90
88
  this.addUnlockHandlers();
91
89
  } else if (this.isLocked && this.context.state === 'running') {
92
90
  this.removeUnlockHandlers();
@@ -94,6 +92,9 @@ export class SoundManager {
94
92
  });
95
93
  }
96
94
 
95
+ /**
96
+ * TBD.
97
+ */
97
98
  addUnlockHandlers() {
98
99
  this.isLocked = true;
99
100
  this.onChange.dispatch('addUnlockHandlers', {
@@ -106,6 +107,9 @@ export class SoundManager {
106
107
  document.body.addEventListener('keydown', this.onUnlockEventBinded, false);
107
108
  }
108
109
 
110
+ /**
111
+ * TBD.
112
+ */
109
113
  removeUnlockHandlers() {
110
114
  this.isLocked = false;
111
115
  this.onChange.dispatch('removeUnlockHandlers', {
@@ -118,6 +122,10 @@ export class SoundManager {
118
122
  document.body.removeEventListener('keydown', this.onUnlockEventBinded);
119
123
  }
120
124
 
125
+ /**
126
+ * TBD.
127
+ * @param event
128
+ */
121
129
  onUnlockEvent(event) {
122
130
  const initialState = this.context.state;
123
131
  if (initialState !== 'suspended' && initialState !== 'interrupted') {
@@ -156,6 +164,9 @@ export class SoundManager {
156
164
  });
157
165
  }
158
166
 
167
+ /**
168
+ * TBD.
169
+ */
159
170
  stopAll() {
160
171
  if (this.noAudio) {
161
172
  return;
@@ -167,6 +178,9 @@ export class SoundManager {
167
178
  }
168
179
  }
169
180
 
181
+ /**
182
+ * TBD.
183
+ */
170
184
  pauseAll() {
171
185
  if (this.noAudio) {
172
186
  return;
@@ -178,6 +192,9 @@ export class SoundManager {
178
192
  }
179
193
  }
180
194
 
195
+ /**
196
+ * TBD.
197
+ */
181
198
  resumeAll() {
182
199
  if (this.noAudio) {
183
200
  return;
@@ -189,6 +206,10 @@ export class SoundManager {
189
206
  }
190
207
  }
191
208
 
209
+ /**
210
+ * TBD.
211
+ * @param {string} key - TBD.
212
+ */
192
213
  decode(key) {
193
214
  const soundData = this.game.cache.getSoundData(key);
194
215
  if (soundData) {
@@ -206,6 +227,12 @@ export class SoundManager {
206
227
  }
207
228
  }
208
229
 
230
+ /**
231
+ * TBD.
232
+ * @param files
233
+ * @param callback - TBD.
234
+ * @param callbackContext
235
+ */
209
236
  setDecodedCallback(files, callback, callbackContext) {
210
237
  if (typeof files === 'string') {
211
238
  files = [files];
@@ -231,6 +258,9 @@ export class SoundManager {
231
258
  }
232
259
  }
233
260
 
261
+ /**
262
+ * TBD.
263
+ */
234
264
  update() {
235
265
  if (this.noAudio) {
236
266
  return;
@@ -253,16 +283,31 @@ export class SoundManager {
253
283
  }
254
284
  }
255
285
 
286
+ /**
287
+ * TBD.
288
+ * @param {string} key - TBD.
289
+ * @param volume - TBD.
290
+ * @param loop
291
+ * @param connect
292
+ */
256
293
  add(key, volume = 1, loop = false, connect = this.connectToMaster) {
257
294
  const sound = new Sound(this.game, key, volume, loop, connect);
258
295
  this._sounds.push(sound);
259
296
  return sound;
260
297
  }
261
298
 
299
+ /**
300
+ * TBD.
301
+ * @param {string} key - TBD.
302
+ */
262
303
  addSprite(key) {
263
304
  return new SoundSprite(this.game, key);
264
305
  }
265
306
 
307
+ /**
308
+ * TBD.
309
+ * @param sound
310
+ */
266
311
  remove(sound) {
267
312
  let i = this._sounds.length;
268
313
  while (i) {
@@ -276,6 +321,10 @@ export class SoundManager {
276
321
  return false;
277
322
  }
278
323
 
324
+ /**
325
+ * TBD.
326
+ * @param {string} key - TBD.
327
+ */
279
328
  removeByKey(key) {
280
329
  let i = this._sounds.length;
281
330
  let removed = 0;
@@ -290,6 +339,12 @@ export class SoundManager {
290
339
  return removed;
291
340
  }
292
341
 
342
+ /**
343
+ * TBD.
344
+ * @param {string} key - TBD.
345
+ * @param volume - TBD.
346
+ * @param loop
347
+ */
293
348
  play(key, volume = 1, loop = false) {
294
349
  if (this.noAudio) {
295
350
  return null;
@@ -299,6 +354,9 @@ export class SoundManager {
299
354
  return sound;
300
355
  }
301
356
 
357
+ /**
358
+ * TBD.
359
+ */
302
360
  setMute() {
303
361
  if (this._muted) {
304
362
  return;
@@ -311,6 +369,9 @@ export class SoundManager {
311
369
  this.onChange.dispatch('muted');
312
370
  }
313
371
 
372
+ /**
373
+ * TBD.
374
+ */
314
375
  unsetMute() {
315
376
  if (!this._muted || this._codeMuted) {
316
377
  return;
@@ -322,6 +383,9 @@ export class SoundManager {
322
383
  this.onChange.dispatch('unmuted');
323
384
  }
324
385
 
386
+ /**
387
+ * TBD.
388
+ */
325
389
  destroy() {
326
390
  this.stopAll();
327
391
  for (let i = 0; i < this._sounds.length; i += 1) {
@@ -340,10 +404,16 @@ export class SoundManager {
340
404
  }
341
405
  }
342
406
 
407
+ /**
408
+ * TBD.
409
+ */
343
410
  get mute() {
344
411
  return this._muted;
345
412
  }
346
413
 
414
+ /**
415
+ * TBD.
416
+ */
347
417
  set mute(value) {
348
418
  if (value || false) {
349
419
  if (this._muted) {
@@ -360,10 +430,16 @@ export class SoundManager {
360
430
  }
361
431
  }
362
432
 
433
+ /**
434
+ * TBD.
435
+ */
363
436
  get volume() {
364
437
  return this._volume;
365
438
  }
366
439
 
440
+ /**
441
+ * TBD.
442
+ */
367
443
  set volume(value) {
368
444
  if (value < 0) {
369
445
  value = 0;
@@ -1,9 +1,11 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- */
1
+ import { Game } from './game';
2
+
6
3
  export class SoundSprite {
4
+ /**
5
+ * TBD.
6
+ * @param {Game} game - TBD.
7
+ * @param {string} key - TBD.
8
+ */
7
9
  constructor(game, key) {
8
10
  this.game = game;
9
11
  this.key = key;
@@ -24,10 +26,19 @@ export class SoundSprite {
24
26
  }
25
27
  }
26
28
 
29
+ /**
30
+ * TBD.
31
+ * @param marker
32
+ * @param volume - TBD.
33
+ */
27
34
  play(marker, volume = 1) {
28
35
  return this.sounds[marker].play(marker, null, volume);
29
36
  }
30
37
 
38
+ /**
39
+ * TBD.
40
+ * @param marker
41
+ */
31
42
  stop(marker) {
32
43
  if (!marker) {
33
44
  for (let key in this.sounds) {
@@ -38,6 +49,10 @@ export class SoundSprite {
38
49
  }
39
50
  }
40
51
 
52
+ /**
53
+ * TBD.
54
+ * @param marker
55
+ */
41
56
  get(marker) {
42
57
  return this.sounds[marker];
43
58
  }
@@ -1,15 +1,15 @@
1
- /**
2
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
3
- * @author Andras Csizmadia <andras@vpmedia.hu>
4
- * @author Richard Davey <rich@photonstorm.com>
5
- */
6
- import { Matrix } from '../geom/matrix';
7
- import { DisplayObject } from '../display/display_object';
1
+ import { Matrix } from '../geom/matrix';
2
+ import { DisplayObject } from '../display/display_object';
8
3
  import { setUserSelect, setTouchAction } from '../display/canvas/util';
9
4
  import { valueToColor } from '../util/math';
10
5
  import { SCALE_LINEAR, SCALE_NEAREST } from './const';
6
+ import { Game } from './game';
11
7
 
12
8
  export class Stage extends DisplayObject {
9
+ /**
10
+ * TBD.
11
+ * @param {Game} game - TBD.
12
+ */
13
13
  constructor(game) {
14
14
  super();
15
15
  this.game = game;
@@ -33,6 +33,10 @@ export class Stage extends DisplayObject {
33
33
  }
34
34
  }
35
35
 
36
+ /**
37
+ * TBD.
38
+ * @param {number} color - TBD.
39
+ */
36
40
  setBackgroundColor(color) {
37
41
  if (this.game.config.transparent) {
38
42
  return;
@@ -45,11 +49,17 @@ export class Stage extends DisplayObject {
45
49
  this._bgColor.a = 1;
46
50
  }
47
51
 
52
+ /**
53
+ * TBD.
54
+ */
48
55
  boot() {
49
56
  setUserSelect(this.game.canvas, 'none');
50
57
  setTouchAction(this.game.canvas, 'none');
51
58
  }
52
59
 
60
+ /**
61
+ * TBD.
62
+ */
53
63
  preUpdate() {
54
64
  this.currentRenderOrderID = 0;
55
65
  // This can't loop in reverse, we need the renderOrderID to be in sequence
@@ -58,6 +68,9 @@ export class Stage extends DisplayObject {
58
68
  }
59
69
  }
60
70
 
71
+ /**
72
+ * TBD.
73
+ */
61
74
  update() {
62
75
  let i = this.children.length;
63
76
  while (i) {
@@ -66,6 +79,9 @@ export class Stage extends DisplayObject {
66
79
  }
67
80
  }
68
81
 
82
+ /**
83
+ * TBD.
84
+ */
69
85
  postUpdate() {
70
86
  for (let i = 0; i < this.children.length; i += 1) {
71
87
  this.children[i].postUpdate();
@@ -73,6 +89,9 @@ export class Stage extends DisplayObject {
73
89
  this.updateTransform();
74
90
  }
75
91
 
92
+ /**
93
+ * TBD.
94
+ */
76
95
  updateTransform() {
77
96
  this.worldAlpha = 1;
78
97
  for (let i = 0; i < this.children.length; i += 1) {
@@ -80,6 +99,9 @@ export class Stage extends DisplayObject {
80
99
  }
81
100
  }
82
101
 
102
+ /**
103
+ * TBD.
104
+ */
83
105
  destroy() {
84
106
  this.exists = false;
85
107
  this.game = null;
@@ -87,18 +109,32 @@ export class Stage extends DisplayObject {
87
109
  this._bgColor = null;
88
110
  }
89
111
 
112
+ /**
113
+ * TBD.
114
+ * @returns {number} TBD.
115
+ */
90
116
  get backgroundColor() {
91
117
  return this._bgColor.color;
92
118
  }
93
119
 
120
+ /**
121
+ * TBD.
122
+ */
94
123
  set backgroundColor(value) {
95
124
  this.setBackgroundColor(value);
96
125
  }
97
126
 
127
+ /**
128
+ * TBD.
129
+ * @returns {boolean} TBD.
130
+ */
98
131
  get smoothed() {
99
132
  return window.PhaserRegistry.TEXTURE_SCALE_MODE === SCALE_LINEAR;
100
133
  }
101
134
 
135
+ /**
136
+ * TBD.
137
+ */
102
138
  set smoothed(value) {
103
139
  window.PhaserRegistry.TEXTURE_SCALE_MODE = value ? SCALE_LINEAR : SCALE_NEAREST;
104
140
  }