@vpmedia/phaser 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/README.md +3 -3
  2. package/package.json +6 -5
  3. package/src/index.js +15 -18
  4. package/src/phaser/core/animation.js +114 -6
  5. package/src/phaser/core/animation_manager.js +102 -10
  6. package/src/phaser/core/animation_parser.js +6 -19
  7. package/src/phaser/core/array_set.js +59 -5
  8. package/src/phaser/core/cache.js +307 -6
  9. package/src/phaser/core/const.js +107 -4
  10. package/src/phaser/core/device.js +3 -6
  11. package/src/phaser/core/device_util.js +3 -16
  12. package/src/phaser/core/dom.js +127 -29
  13. package/src/phaser/core/event_manager.js +128 -6
  14. package/src/phaser/core/factory.js +69 -34
  15. package/src/phaser/core/frame.js +43 -6
  16. package/src/phaser/core/frame_data.js +55 -5
  17. package/src/phaser/core/frame_util.js +7 -12
  18. package/src/phaser/core/game.js +35 -7
  19. package/src/phaser/core/input.js +133 -17
  20. package/src/phaser/core/input_handler.js +243 -43
  21. package/src/phaser/core/input_mouse.js +70 -5
  22. package/src/phaser/core/input_mspointer.js +40 -9
  23. package/src/phaser/core/input_pointer.js +88 -17
  24. package/src/phaser/core/input_touch.js +42 -5
  25. package/src/phaser/core/loader.js +303 -101
  26. package/src/phaser/core/loader_parser.js +2 -10
  27. package/src/phaser/core/raf.js +16 -5
  28. package/src/phaser/core/scale_manager.js +204 -39
  29. package/src/phaser/core/scene.js +24 -5
  30. package/src/phaser/core/scene_manager.js +81 -11
  31. package/src/phaser/core/signal.js +88 -11
  32. package/src/phaser/core/signal_binding.js +35 -15
  33. package/src/phaser/core/sound.js +99 -10
  34. package/src/phaser/core/sound_manager.js +89 -13
  35. package/src/phaser/core/sound_sprite.js +20 -5
  36. package/src/phaser/core/stage.js +43 -7
  37. package/src/phaser/core/time.js +67 -5
  38. package/src/phaser/core/timer.js +107 -30
  39. package/src/phaser/core/timer_event.js +11 -6
  40. package/src/phaser/core/tween.js +124 -30
  41. package/src/phaser/core/tween_data.js +42 -18
  42. package/src/phaser/core/tween_easing.js +1 -8
  43. package/src/phaser/core/tween_manager.js +47 -5
  44. package/src/phaser/core/world.js +9 -6
  45. package/src/phaser/display/bitmap_text.js +91 -10
  46. package/src/phaser/display/button.js +63 -12
  47. package/src/phaser/display/canvas/buffer.js +16 -6
  48. package/src/phaser/display/canvas/graphics.js +1 -13
  49. package/src/phaser/display/canvas/masker.js +0 -6
  50. package/src/phaser/display/canvas/pool.js +0 -7
  51. package/src/phaser/display/canvas/renderer.js +28 -8
  52. package/src/phaser/display/canvas/tinter.js +4 -43
  53. package/src/phaser/display/canvas/util.js +0 -6
  54. package/src/phaser/display/display_object.js +192 -20
  55. package/src/phaser/display/graphics.js +161 -26
  56. package/src/phaser/display/graphics_data.js +14 -6
  57. package/src/phaser/display/graphics_data_util.js +2 -8
  58. package/src/phaser/display/group.js +82 -9
  59. package/src/phaser/display/image.js +87 -9
  60. package/src/phaser/display/sprite_batch.js +3 -8
  61. package/src/phaser/display/sprite_util.js +3 -23
  62. package/src/phaser/display/text.js +331 -31
  63. package/src/phaser/display/webgl/abstract_filter.js +8 -7
  64. package/src/phaser/display/webgl/base_texture.js +20 -12
  65. package/src/phaser/display/webgl/blend_manager.js +14 -7
  66. package/src/phaser/display/webgl/earcut.js +4 -23
  67. package/src/phaser/display/webgl/earcut_node.js +6 -7
  68. package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
  69. package/src/phaser/display/webgl/filter_manager.js +25 -7
  70. package/src/phaser/display/webgl/filter_texture.js +21 -22
  71. package/src/phaser/display/webgl/graphics.js +5 -28
  72. package/src/phaser/display/webgl/graphics_data.js +10 -7
  73. package/src/phaser/display/webgl/mask_manager.js +0 -6
  74. package/src/phaser/display/webgl/render_texture.js +33 -21
  75. package/src/phaser/display/webgl/renderer.js +38 -11
  76. package/src/phaser/display/webgl/shader/complex.js +10 -6
  77. package/src/phaser/display/webgl/shader/fast.js +10 -6
  78. package/src/phaser/display/webgl/shader/normal.js +23 -32
  79. package/src/phaser/display/webgl/shader/primitive.js +10 -6
  80. package/src/phaser/display/webgl/shader/strip.js +10 -6
  81. package/src/phaser/display/webgl/shader_manager.js +18 -6
  82. package/src/phaser/display/webgl/sprite_batch.js +41 -8
  83. package/src/phaser/display/webgl/stencil_manager.js +28 -6
  84. package/src/phaser/display/webgl/texture.js +28 -15
  85. package/src/phaser/display/webgl/texture_util.js +0 -6
  86. package/src/phaser/display/webgl/util.js +0 -7
  87. package/src/phaser/geom/circle.js +123 -18
  88. package/src/phaser/geom/ellipse.js +39 -18
  89. package/src/phaser/geom/line.js +148 -16
  90. package/src/phaser/geom/matrix.js +73 -6
  91. package/src/phaser/geom/point.js +152 -6
  92. package/src/phaser/geom/polygon.js +42 -14
  93. package/src/phaser/geom/rectangle.js +233 -6
  94. package/src/phaser/geom/rounded_rectangle.js +10 -6
  95. package/src/phaser/geom/util/circle.js +3 -9
  96. package/src/phaser/geom/util/ellipse.js +0 -7
  97. package/src/phaser/geom/util/line.js +5 -14
  98. package/src/phaser/geom/util/matrix.js +1 -7
  99. package/src/phaser/geom/util/point.js +0 -6
  100. package/src/phaser/geom/util/polygon.js +1 -7
  101. package/src/phaser/geom/util/rectangle.js +1 -7
  102. package/src/phaser/geom/util/rounded_rectangle.js +1 -7
  103. package/src/phaser/util/math.js +3 -21
  104. package/types/index.d.ts +2 -1
  105. package/types/index.d.ts.map +1 -1
  106. package/types/phaser/core/animation.d.ts +126 -13
  107. package/types/phaser/core/animation.d.ts.map +1 -1
  108. package/types/phaser/core/animation_manager.d.ts +121 -19
  109. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  110. package/types/phaser/core/animation_parser.d.ts +6 -5
  111. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  112. package/types/phaser/core/array_set.d.ts +67 -13
  113. package/types/phaser/core/array_set.d.ts.map +1 -1
  114. package/types/phaser/core/cache.d.ts +365 -69
  115. package/types/phaser/core/cache.d.ts.map +1 -1
  116. package/types/phaser/core/const.d.ts +143 -40
  117. package/types/phaser/core/const.d.ts.map +1 -1
  118. package/types/phaser/core/device.d.ts +0 -5
  119. package/types/phaser/core/device.d.ts.map +1 -1
  120. package/types/phaser/core/device_util.d.ts +1 -1
  121. package/types/phaser/core/device_util.d.ts.map +1 -1
  122. package/types/phaser/core/dom.d.ts +119 -0
  123. package/types/phaser/core/dom.d.ts.map +1 -1
  124. package/types/phaser/core/event_manager.d.ts +127 -0
  125. package/types/phaser/core/event_manager.d.ts.map +1 -1
  126. package/types/phaser/core/factory.d.ts +75 -8
  127. package/types/phaser/core/factory.d.ts.map +1 -1
  128. package/types/phaser/core/frame.d.ts +64 -21
  129. package/types/phaser/core/frame.d.ts.map +1 -1
  130. package/types/phaser/core/frame_data.d.ts +61 -9
  131. package/types/phaser/core/frame_data.d.ts.map +1 -1
  132. package/types/phaser/core/frame_util.d.ts +10 -8
  133. package/types/phaser/core/frame_util.d.ts.map +1 -1
  134. package/types/phaser/core/game.d.ts +40 -6
  135. package/types/phaser/core/game.d.ts.map +1 -1
  136. package/types/phaser/core/input.d.ts +143 -15
  137. package/types/phaser/core/input.d.ts.map +1 -1
  138. package/types/phaser/core/input_handler.d.ts +258 -25
  139. package/types/phaser/core/input_handler.d.ts.map +1 -1
  140. package/types/phaser/core/input_mouse.d.ts +62 -14
  141. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  142. package/types/phaser/core/input_mspointer.d.ts +51 -17
  143. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  144. package/types/phaser/core/input_pointer.d.ts +99 -14
  145. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  146. package/types/phaser/core/input_touch.d.ts +53 -16
  147. package/types/phaser/core/input_touch.d.ts.map +1 -1
  148. package/types/phaser/core/loader.d.ts +299 -28
  149. package/types/phaser/core/loader.d.ts.map +1 -1
  150. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  151. package/types/phaser/core/raf.d.ts +19 -9
  152. package/types/phaser/core/raf.d.ts.map +1 -1
  153. package/types/phaser/core/scale_manager.d.ts +208 -13
  154. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  155. package/types/phaser/core/scene.d.ts +21 -5
  156. package/types/phaser/core/scene.d.ts.map +1 -1
  157. package/types/phaser/core/scene_manager.d.ts +90 -10
  158. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  159. package/types/phaser/core/signal.d.ts +93 -9
  160. package/types/phaser/core/signal.d.ts.map +1 -1
  161. package/types/phaser/core/signal_binding.d.ts +34 -5
  162. package/types/phaser/core/signal_binding.d.ts.map +1 -1
  163. package/types/phaser/core/sound.d.ts +111 -14
  164. package/types/phaser/core/sound.d.ts.map +1 -1
  165. package/types/phaser/core/sound_manager.d.ts +97 -11
  166. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  167. package/types/phaser/core/sound_sprite.d.ts +22 -8
  168. package/types/phaser/core/sound_sprite.d.ts.map +1 -1
  169. package/types/phaser/core/stage.d.ts +32 -3
  170. package/types/phaser/core/stage.d.ts.map +1 -1
  171. package/types/phaser/core/time.d.ts +73 -6
  172. package/types/phaser/core/time.d.ts.map +1 -1
  173. package/types/phaser/core/timer.d.ts +108 -7
  174. package/types/phaser/core/timer.d.ts.map +1 -1
  175. package/types/phaser/core/timer_event.d.ts +13 -7
  176. package/types/phaser/core/timer_event.d.ts.map +1 -1
  177. package/types/phaser/core/tween.d.ts +124 -4
  178. package/types/phaser/core/tween.d.ts.map +1 -1
  179. package/types/phaser/core/tween_data.d.ts +41 -2
  180. package/types/phaser/core/tween_data.d.ts.map +1 -1
  181. package/types/phaser/core/tween_easing.d.ts +0 -5
  182. package/types/phaser/core/tween_easing.d.ts.map +1 -1
  183. package/types/phaser/core/tween_manager.d.ts +49 -2
  184. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  185. package/types/phaser/core/world.d.ts +9 -1
  186. package/types/phaser/core/world.d.ts.map +1 -1
  187. package/types/phaser/display/bitmap_text.d.ts +84 -7
  188. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  189. package/types/phaser/display/button.d.ts +65 -8
  190. package/types/phaser/display/button.d.ts.map +1 -1
  191. package/types/phaser/display/canvas/buffer.d.ts +20 -4
  192. package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
  193. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  194. package/types/phaser/display/canvas/masker.d.ts.map +1 -1
  195. package/types/phaser/display/canvas/pool.d.ts +0 -6
  196. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  197. package/types/phaser/display/canvas/renderer.d.ts +29 -2
  198. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  199. package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
  200. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  201. package/types/phaser/display/display_object.d.ts +195 -8
  202. package/types/phaser/display/display_object.d.ts.map +1 -1
  203. package/types/phaser/display/graphics.d.ts +132 -6
  204. package/types/phaser/display/graphics.d.ts.map +1 -1
  205. package/types/phaser/display/graphics_data.d.ts +15 -1
  206. package/types/phaser/display/graphics_data.d.ts.map +1 -1
  207. package/types/phaser/display/graphics_data_util.d.ts +3 -2
  208. package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
  209. package/types/phaser/display/group.d.ts +80 -10
  210. package/types/phaser/display/group.d.ts.map +1 -1
  211. package/types/phaser/display/image.d.ts +72 -6
  212. package/types/phaser/display/image.d.ts.map +1 -1
  213. package/types/phaser/display/sprite_batch.d.ts +4 -3
  214. package/types/phaser/display/sprite_batch.d.ts.map +1 -1
  215. package/types/phaser/display/sprite_util.d.ts.map +1 -1
  216. package/types/phaser/display/text.d.ts +366 -46
  217. package/types/phaser/display/text.d.ts.map +1 -1
  218. package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
  219. package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
  220. package/types/phaser/display/webgl/base_texture.d.ts +20 -1
  221. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  222. package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
  223. package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
  224. package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
  225. package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
  226. package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
  227. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
  228. package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
  229. package/types/phaser/display/webgl/filter_manager.d.ts +22 -6
  230. package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
  231. package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
  232. package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
  233. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  234. package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
  235. package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
  236. package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
  237. package/types/phaser/display/webgl/render_texture.d.ts +30 -3
  238. package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
  239. package/types/phaser/display/webgl/renderer.d.ts +41 -4
  240. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  241. package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
  242. package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
  243. package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
  244. package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
  245. package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
  246. package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
  247. package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
  248. package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
  249. package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
  250. package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
  251. package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
  252. package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
  253. package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
  254. package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
  255. package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
  256. package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
  257. package/types/phaser/display/webgl/texture.d.ts +21 -0
  258. package/types/phaser/display/webgl/texture.d.ts.map +1 -1
  259. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  260. package/types/phaser/display/webgl/util.d.ts +0 -6
  261. package/types/phaser/display/webgl/util.d.ts.map +1 -1
  262. package/types/phaser/geom/circle.d.ts +131 -9
  263. package/types/phaser/geom/circle.d.ts.map +1 -1
  264. package/types/phaser/geom/ellipse.d.ts +43 -5
  265. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  266. package/types/phaser/geom/line.d.ts +159 -13
  267. package/types/phaser/geom/line.d.ts.map +1 -1
  268. package/types/phaser/geom/matrix.d.ts +85 -11
  269. package/types/phaser/geom/matrix.d.ts.map +1 -1
  270. package/types/phaser/geom/point.d.ts +170 -18
  271. package/types/phaser/geom/point.d.ts.map +1 -1
  272. package/types/phaser/geom/polygon.d.ts +45 -5
  273. package/types/phaser/geom/polygon.d.ts.map +1 -1
  274. package/types/phaser/geom/rectangle.d.ts +253 -20
  275. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  276. package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
  277. package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
  278. package/types/phaser/geom/util/circle.d.ts +3 -3
  279. package/types/phaser/geom/util/circle.d.ts.map +1 -1
  280. package/types/phaser/geom/util/ellipse.d.ts +0 -6
  281. package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
  282. package/types/phaser/geom/util/line.d.ts +5 -5
  283. package/types/phaser/geom/util/line.d.ts.map +1 -1
  284. package/types/phaser/geom/util/matrix.d.ts.map +1 -1
  285. package/types/phaser/geom/util/point.d.ts.map +1 -1
  286. package/types/phaser/geom/util/polygon.d.ts.map +1 -1
  287. package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
  288. package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
  289. package/types/phaser/util/math.d.ts +0 -5
  290. package/types/phaser/util/math.d.ts.map +1 -1
@@ -1,11 +1,12 @@
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';
6
2
  import { Scene } from './scene';
7
3
 
8
4
  export class SceneManager {
5
+ /**
6
+ * TBD.
7
+ * @param {Game} game - TBD.
8
+ * @param pendingState - TBD.
9
+ */
9
10
  constructor(game, pendingState) {
10
11
  this.game = game;
11
12
  this.states = {};
@@ -27,12 +28,21 @@ export class SceneManager {
27
28
  this.onShutDownCallback = null;
28
29
  }
29
30
 
31
+ /**
32
+ * TBD.
33
+ */
30
34
  boot() {
31
35
  if (this._pendingState !== null && typeof this._pendingState !== 'string') {
32
36
  this.add('default', this._pendingState, true);
33
37
  }
34
38
  }
35
39
 
40
+ /**
41
+ * TBD.
42
+ * @param {string} key - TBD.
43
+ * @param state - TBD.
44
+ * @param autoStart - TBD.
45
+ */
36
46
  add(key, state, autoStart = false) {
37
47
  let newState = null;
38
48
  if (state instanceof Scene) {
@@ -54,6 +64,10 @@ export class SceneManager {
54
64
  return newState;
55
65
  }
56
66
 
67
+ /**
68
+ * TBD.
69
+ * @param {string} key - TBD.
70
+ */
57
71
  remove(key) {
58
72
  if (this.current === key) {
59
73
  this.callbackContext = null;
@@ -68,6 +82,13 @@ export class SceneManager {
68
82
  delete this.states[key];
69
83
  }
70
84
 
85
+ /**
86
+ * TBD.
87
+ * @param {string} key - TBD.
88
+ * @param clearWorld - TBD.
89
+ * @param clearCache - TBD.
90
+ * @param {...any} args - TBD.
91
+ */
71
92
  start(key, clearWorld = true, clearCache = false, ...args) {
72
93
  if (this.checkState(key)) {
73
94
  // Place the state in the queue. It will be started the next time the game loop begins.
@@ -80,6 +101,12 @@ export class SceneManager {
80
101
  }
81
102
  }
82
103
 
104
+ /**
105
+ * TBD.
106
+ * @param clearWorld - TBD.
107
+ * @param clearCache - TBD.
108
+ * @param {...any} args - TBD.
109
+ */
83
110
  restart(clearWorld = true, clearCache = false, ...args) {
84
111
  this._pendingState = this.current;
85
112
  this._clearWorld = clearWorld;
@@ -89,6 +116,9 @@ export class SceneManager {
89
116
  }
90
117
  }
91
118
 
119
+ /**
120
+ * TBD.
121
+ */
92
122
  preUpdate() {
93
123
  if (this._pendingState && this.game.isBooted) {
94
124
  // var previousStateKey = this.current;
@@ -120,6 +150,9 @@ export class SceneManager {
120
150
  }
121
151
  }
122
152
 
153
+ /**
154
+ * TBD.
155
+ */
123
156
  clearCurrentState() {
124
157
  if (this.current) {
125
158
  if (this.onShutDownCallback) {
@@ -138,14 +171,13 @@ export class SceneManager {
138
171
  }
139
172
  }
140
173
 
174
+ /**
175
+ * TBD.
176
+ * @param {string} key - TBD.
177
+ */
141
178
  checkState(key) {
142
179
  if (this.states[key]) {
143
- if (
144
- this.states[key].preload ||
145
- this.states[key].create ||
146
- this.states[key].update ||
147
- this.states[key].render
148
- ) {
180
+ if (this.states[key].preload || this.states[key].create || this.states[key].update || this.states[key].render) {
149
181
  return true;
150
182
  }
151
183
  return false;
@@ -153,17 +185,29 @@ export class SceneManager {
153
185
  return false;
154
186
  }
155
187
 
188
+ /**
189
+ * TBD.
190
+ * @param {string} key - TBD.
191
+ */
156
192
  link(key) {
157
193
  this.states[key].game = this.game;
158
194
  this.states[key].key = key;
159
195
  }
160
196
 
197
+ /**
198
+ * TBD.
199
+ * @param {string} key - TBD.
200
+ */
161
201
  unlink(key) {
162
202
  if (this.states[key]) {
163
203
  this.states[key].game = null;
164
204
  }
165
205
  }
166
206
 
207
+ /**
208
+ * TBD.
209
+ * @param {string} key - TBD.
210
+ */
167
211
  setCurrentState(key) {
168
212
  this.callbackContext = this.states[key];
169
213
  this.link(key);
@@ -184,10 +228,16 @@ export class SceneManager {
184
228
  this.game.isKickStart = true;
185
229
  }
186
230
 
231
+ /**
232
+ * TBD.
233
+ */
187
234
  getCurrentState() {
188
235
  return this.states[this.current];
189
236
  }
190
237
 
238
+ /**
239
+ * TBD.
240
+ */
191
241
  loadComplete() {
192
242
  if (this._created === false && this.onCreateCallback) {
193
243
  this._created = true;
@@ -197,24 +247,38 @@ export class SceneManager {
197
247
  }
198
248
  }
199
249
 
250
+ /**
251
+ * TBD.
252
+ */
200
253
  update() {
201
254
  if (this._created && this.onUpdateCallback) {
202
255
  this.onUpdateCallback.call(this.callbackContext, this.game);
203
256
  }
204
257
  }
205
258
 
259
+ /**
260
+ * TBD.
261
+ */
206
262
  pauseUpdate() {
207
263
  if (this._created && this.onPauseUpdateCallback) {
208
264
  this.onPauseUpdateCallback.call(this.callbackContext, this.game);
209
265
  }
210
266
  }
211
267
 
268
+ /**
269
+ * TBD.
270
+ * @param {number} width - TBD.
271
+ * @param {number} height - TBD.
272
+ */
212
273
  resize(width, height) {
213
274
  if (this.onResizeCallback) {
214
275
  this.onResizeCallback.call(this.callbackContext, width, height);
215
276
  }
216
277
  }
217
278
 
279
+ /**
280
+ * TBD.
281
+ */
218
282
  destroy() {
219
283
  this._clearWorld = true;
220
284
  this._clearCache = true;
@@ -232,10 +296,16 @@ export class SceneManager {
232
296
  this.current = '';
233
297
  }
234
298
 
299
+ /**
300
+ * TBD.
301
+ */
235
302
  dummy() {
236
303
  // pass
237
304
  }
238
305
 
306
+ /**
307
+ * TBD.
308
+ */
239
309
  get created() {
240
310
  return this._created;
241
311
  }
@@ -1,12 +1,9 @@
1
- /**
2
- * @module core/signal
3
- * @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
4
- * @author Andras Csizmadia <andras@vpmedia.hu>
5
- * @author Richard Davey <rich@photonstorm.com>
6
- */
7
- import { SignalBinding } from './signal_binding';
1
+ import { SignalBinding } from './signal_binding';
8
2
 
9
3
  export class Signal {
4
+ /**
5
+ * TBD.
6
+ */
10
7
  constructor() {
11
8
  this._bindings = null;
12
9
  this._prevParams = null;
@@ -16,17 +13,30 @@ export class Signal {
16
13
  this._boundDispatch = false;
17
14
  }
18
15
 
16
+ /**
17
+ * TBD.
18
+ * @param {Function} listener - TBD.
19
+ * @param {string} fnName - TBD.
20
+ * @throws Error.
21
+ */
19
22
  validateListener(listener, fnName) {
20
23
  if (typeof listener !== 'function') {
21
24
  throw new Error(
22
- 'Signal: listener is a required param of {fn}() and should be a Function.'.replace(
23
- '{fn}',
24
- fnName
25
- )
25
+ 'Signal: listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName)
26
26
  );
27
27
  }
28
28
  }
29
29
 
30
+ /**
31
+ * TBD.
32
+ * @param {Function} listener - TBD.
33
+ * @param {boolean} isOnce - TBD.
34
+ * @param {object} listenerContext - TBD.
35
+ * @param {number} priority - TBD.
36
+ * @param {...any} args - TBD.
37
+ * @returns {SignalBinding} TBD.
38
+ * @throws Error.
39
+ */
30
40
  _registerListener(listener, isOnce, listenerContext, priority, args) {
31
41
  const prevIndex = this._indexOfListener(listener, listenerContext);
32
42
  let binding;
@@ -51,6 +61,10 @@ export class Signal {
51
61
  return binding;
52
62
  }
53
63
 
64
+ /**
65
+ * TBD.
66
+ * @param {SignalBinding} binding - TBD.
67
+ */
54
68
  _addBinding(binding) {
55
69
  if (!this._bindings) {
56
70
  this._bindings = [];
@@ -63,6 +77,12 @@ export class Signal {
63
77
  this._bindings.splice(n + 1, 0, binding);
64
78
  }
65
79
 
80
+ /**
81
+ * TBD.
82
+ * @param {Function} listener - TBD.
83
+ * @param {object} context - TBD.
84
+ * @returns {number} TBD.
85
+ */
66
86
  _indexOfListener(listener, context = null) {
67
87
  if (!this._bindings) {
68
88
  return -1;
@@ -79,20 +99,48 @@ export class Signal {
79
99
  return -1;
80
100
  }
81
101
 
102
+ /**
103
+ * TBD.
104
+ * @param {Function} listener - TBD.
105
+ * @param {object} context - TBD.
106
+ * @returns {boolean} TBD.
107
+ */
82
108
  has(listener, context) {
83
109
  return this._indexOfListener(listener, context) !== -1;
84
110
  }
85
111
 
112
+ /**
113
+ * TBD.
114
+ * @param {Function} listener - TBD.
115
+ * @param {object} listenerContext - TBD.
116
+ * @param {number} priority - TBD.
117
+ * @param {...any} args - TBD.
118
+ * @returns {SignalBinding} TBD.
119
+ */
86
120
  add(listener, listenerContext, priority, ...args) {
87
121
  this.validateListener(listener, 'add');
88
122
  return this._registerListener(listener, false, listenerContext, priority, args);
89
123
  }
90
124
 
125
+ /**
126
+ * TBD.
127
+ * @param {Function} listener - TBD.
128
+ * @param {object} listenerContext - TBD.
129
+ * @param {number} priority - TBD.
130
+ * @param {...any} args - TBD.
131
+ * @returns {SignalBinding} TBD.
132
+ */
91
133
  addOnce(listener, listenerContext, priority, ...args) {
92
134
  this.validateListener(listener, 'addOnce');
93
135
  return this._registerListener(listener, true, listenerContext, priority, args);
94
136
  }
95
137
 
138
+ /**
139
+ * TBD.
140
+ * @param {Function} listener - TBD.
141
+ * @param {object} context - TBD.
142
+ * @returns {Function} TBD.
143
+ */
96
144
  remove(listener, context) {
97
145
  this.validateListener(listener, 'remove');
98
146
  const i = this._indexOfListener(listener, context);
@@ -104,6 +152,10 @@ export class Signal {
104
152
  return listener;
105
153
  }
106
154
 
155
+ /**
156
+ * TBD.
157
+ * @param {object} context - TBD.
158
+ */
107
159
  removeAll(context = null) {
108
160
  if (!this._bindings) {
109
161
  return;
@@ -125,14 +177,25 @@ export class Signal {
125
177
  }
126
178
  }
127
179
 
180
+ /**
181
+ * TBD.
182
+ * @returns {number} TBD.
183
+ */
128
184
  getNumListeners() {
129
185
  return this._bindings ? this._bindings.length : 0;
130
186
  }
131
187
 
188
+ /**
189
+ * TBD.
190
+ */
132
191
  halt() {
133
192
  this._shouldPropagate = false;
134
193
  }
135
194
 
195
+ /**
196
+ * TBD.
197
+ * @param {...any} args - TBD.
198
+ */
136
199
  dispatch(...args) {
137
200
  if (!this.active || !this._bindings) {
138
201
  return;
@@ -157,22 +220,36 @@ export class Signal {
157
220
  } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
158
221
  }
159
222
 
223
+ /**
224
+ * TBD.
225
+ */
160
226
  forget() {
161
227
  if (this._prevParams) {
162
228
  this._prevParams = null;
163
229
  }
164
230
  }
165
231
 
232
+ /**
233
+ * TBD.
234
+ */
166
235
  dispose() {
167
236
  this.removeAll();
168
237
  this.forget();
169
238
  this._bindings = null;
170
239
  }
171
240
 
241
+ /**
242
+ * TBD.
243
+ * @returns {string} TBD.
244
+ */
172
245
  toString() {
173
246
  return '[Signal active:' + this.active + ' numListeners:' + this.getNumListeners() + ']';
174
247
  }
175
248
 
249
+ /**
250
+ * TBD.
251
+ * @returns {boolean} TBD.
252
+ */
176
253
  get boundDispatch() {
177
254
  const _this = this;
178
255
  if (!this._boundDispatch) {
@@ -1,10 +1,13 @@
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
-
7
1
  export class SignalBinding {
2
+ /**
3
+ * TBD.
4
+ * @param signal
5
+ * @param listener
6
+ * @param isOnce
7
+ * @param listenerContext
8
+ * @param priority
9
+ * @param args - TBD.
10
+ */
8
11
  constructor(signal, listener, isOnce = false, listenerContext = null, priority = 0, args = null) {
9
12
  this._signal = signal;
10
13
  this._listener = listener;
@@ -17,6 +20,10 @@ export class SignalBinding {
17
20
  this.params = null;
18
21
  }
19
22
 
23
+ /**
24
+ * TBD.
25
+ * @param paramsArr
26
+ */
20
27
  execute(paramsArr) {
21
28
  let handlerReturn;
22
29
  let params;
@@ -34,41 +41,54 @@ export class SignalBinding {
34
41
  return handlerReturn;
35
42
  }
36
43
 
44
+ /**
45
+ * TBD.
46
+ */
37
47
  detach() {
38
48
  return this.isBound() ? this._signal.remove(this._listener, this.context) : null;
39
49
  }
40
50
 
51
+ /**
52
+ * TBD.
53
+ */
41
54
  isBound() {
42
55
  return !!this._signal && !!this._listener;
43
56
  }
44
57
 
58
+ /**
59
+ * TBD.
60
+ */
45
61
  isOnce() {
46
62
  return this._isOnce;
47
63
  }
48
64
 
65
+ /**
66
+ * TBD.
67
+ */
49
68
  getListener() {
50
69
  return this._listener;
51
70
  }
52
71
 
72
+ /**
73
+ * TBD.
74
+ */
53
75
  getSignal() {
54
76
  return this._signal;
55
77
  }
56
78
 
79
+ /**
80
+ * TBD.
81
+ */
57
82
  _destroy() {
58
83
  delete this._signal;
59
84
  delete this._listener;
60
85
  delete this.context;
61
86
  }
62
87
 
88
+ /**
89
+ * TBD.
90
+ */
63
91
  toString() {
64
- return (
65
- '[SignalBinding isOnce:' +
66
- this._isOnce +
67
- ', isBound:' +
68
- this.isBound() +
69
- ', active:' +
70
- this.active +
71
- ']'
72
- );
92
+ return '[SignalBinding isOnce:' + this._isOnce + ', isBound:' + this.isBound() + ', active:' + this.active + ']';
73
93
  }
74
94
  }