@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,12 +1,6 @@
1
- /**
2
- * @module core/game
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
1
  import { CanvasRenderer } from '../display/canvas/renderer';
8
2
  import { WebGLRenderer } from '../display/webgl/renderer';
9
- import { Signal } from './signal';
3
+ import { Signal } from './signal';
10
4
  import { Loader } from './loader';
11
5
  import { Cache } from './cache';
12
6
  import { Input } from './input';
@@ -25,6 +19,10 @@ import { create, removeFromDOM, addToDOM, setTouchAction } from '../display/canv
25
19
  import { initialize, checkOS } from './device_util';
26
20
 
27
21
  export class Game {
22
+ /**
23
+ * TBD.
24
+ * @param {object} gameConfig - TBD.
25
+ */
28
26
  constructor(gameConfig = {}) {
29
27
  if (!window.PhaserRegistry) {
30
28
  window.PhaserRegistry = {};
@@ -72,6 +70,9 @@ export class Game {
72
70
  }
73
71
  }
74
72
 
73
+ /**
74
+ * TBD.
75
+ */
75
76
  boot() {
76
77
  if (this.isBooted) {
77
78
  return;
@@ -105,6 +106,9 @@ export class Game {
105
106
  this.onBoot.dispatch(this);
106
107
  }
107
108
 
109
+ /**
110
+ * TBD.
111
+ */
108
112
  initRenderer() {
109
113
  if (this.config.canvas) {
110
114
  this.canvas = this.config.canvas;
@@ -165,6 +169,12 @@ export class Game {
165
169
  setTouchAction(this.canvas);
166
170
  }
167
171
 
172
+ /**
173
+ * TBD.
174
+ * @param {object} config - TBD.
175
+ * @param {string} key - TBD.
176
+ * @param {*} defaultValue - TBD.
177
+ */
168
178
  parseConfigElement(config, key, defaultValue) {
169
179
  if (config[key] !== undefined) {
170
180
  this.config[key] = config[key];
@@ -173,6 +183,10 @@ export class Game {
173
183
  }
174
184
  }
175
185
 
186
+ /**
187
+ * TBD.
188
+ * @param {object} config - TBD.
189
+ */
176
190
  parseConfig(config) {
177
191
  this.parseConfigElement(config, 'width', 800);
178
192
  this.parseConfigElement(config, 'height', 600);
@@ -205,6 +219,10 @@ export class Game {
205
219
  this.state = new SceneManager(this, state);
206
220
  }
207
221
 
222
+ /**
223
+ * TBD.
224
+ * @param {Event} event - TBD.
225
+ */
208
226
  contextLost(event) {
209
227
  event.preventDefault();
210
228
  if (this.renderer) {
@@ -212,6 +230,9 @@ export class Game {
212
230
  }
213
231
  }
214
232
 
233
+ /**
234
+ * TBD.
235
+ */
215
236
  contextRestored() {
216
237
  this.renderer.initContext();
217
238
  // this.cache.clearGLTextures();
@@ -220,6 +241,10 @@ export class Game {
220
241
  }
221
242
  }
222
243
 
244
+ /**
245
+ * TBD.
246
+ * @param {number} time - TBD.
247
+ */
223
248
  update(time) {
224
249
  this.time.update(time);
225
250
  if (!this.isPaused) {
@@ -240,6 +265,9 @@ export class Game {
240
265
  this.renderer.render(this.stage);
241
266
  }
242
267
 
268
+ /**
269
+ * TBD.
270
+ */
243
271
  destroy() {
244
272
  this.isPaused = true;
245
273
 
@@ -1,24 +1,24 @@
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 { Graphics } from '../display/graphics';
2
+ import { Graphics } from '../display/graphics';
8
3
  import { Image } from '../display/image';
9
- import { Signal } from './signal';
4
+ import { Signal } from './signal';
10
5
  import { Point } from '../geom/point';
11
- import { Circle } from '../geom/circle';
6
+ import { Circle } from '../geom/circle';
12
7
  import { Mouse } from './input_mouse';
13
8
  import { MSPointer } from './input_mspointer';
14
9
  import { Pointer } from './input_pointer';
15
10
  import { Touch } from './input_touch';
16
11
  import { POINTER_CURSOR, POINTER_CONTACT, MOUSE_TOUCH_COMBINE } from './const';
17
12
  import { create, remove } from '../display/canvas/pool';
13
+ import { Game } from './game';
18
14
 
19
15
  const MAX_POINTERS = 10;
20
16
 
21
17
  export class Input {
18
+ /**
19
+ * TBD.
20
+ * @param {Game} game - TBD.
21
+ */
22
22
  constructor(game) {
23
23
  this.game = game;
24
24
  this.hitCanvas = null;
@@ -73,6 +73,9 @@ export class Input {
73
73
  this._y = 0;
74
74
  }
75
75
 
76
+ /**
77
+ * TBD.
78
+ */
76
79
  boot() {
77
80
  this.mousePointer = new Pointer(this.game, 0, POINTER_CURSOR);
78
81
  this.addPointer();
@@ -104,6 +107,9 @@ export class Input {
104
107
  this.game.canvas.addEventListener('click', this._onClickTrampoline, false);
105
108
  }
106
109
 
110
+ /**
111
+ * TBD.
112
+ */
107
113
  destroy() {
108
114
  this.mouse.stop();
109
115
  if (this.game.device.mspointer) {
@@ -116,29 +122,44 @@ export class Input {
116
122
  this.game.canvas.removeEventListener('click', this._onClickTrampoline);
117
123
  }
118
124
 
125
+ /**
126
+ * TBD.
127
+ * @param callback - TBD.
128
+ * @param context
129
+ */
119
130
  setInteractiveCandidateHandler(callback, context) {
120
131
  this.customCandidateHandler = callback;
121
132
  this.customCandidateHandlerContext = context;
122
133
  }
123
134
 
135
+ /**
136
+ * TBD.
137
+ * @param callback - TBD.
138
+ * @param context
139
+ */
124
140
  addMoveCallback(callback, context) {
125
141
  this.moveCallbacks.push({ callback, context });
126
142
  }
127
143
 
144
+ /**
145
+ * TBD.
146
+ * @param callback - TBD.
147
+ * @param context
148
+ */
128
149
  deleteMoveCallback(callback, context) {
129
150
  let i = this.moveCallbacks.length;
130
151
  while (i) {
131
152
  i -= 1;
132
- if (
133
- this.moveCallbacks[i].callback === callback &&
134
- this.moveCallbacks[i].context === context
135
- ) {
153
+ if (this.moveCallbacks[i].callback === callback && this.moveCallbacks[i].context === context) {
136
154
  this.moveCallbacks.splice(i, 1);
137
155
  return;
138
156
  }
139
157
  }
140
158
  }
141
159
 
160
+ /**
161
+ * TBD.
162
+ */
142
163
  addPointer() {
143
164
  if (this.pointers.length >= MAX_POINTERS) {
144
165
  console.warn('Input.addPointer: Maximum limit of ' + MAX_POINTERS + ' pointers reached.');
@@ -151,6 +172,9 @@ export class Input {
151
172
  return pointer;
152
173
  }
153
174
 
175
+ /**
176
+ * TBD.
177
+ */
154
178
  update() {
155
179
  if (this.pollRate > 0 && this._pollCounter < this.pollRate) {
156
180
  this._pollCounter += 1;
@@ -166,6 +190,10 @@ export class Input {
166
190
  this._pollCounter = 0;
167
191
  }
168
192
 
193
+ /**
194
+ * TBD.
195
+ * @param hard
196
+ */
169
197
  reset(hard = false) {
170
198
  if (!this.game.isBooted || this.resetLocked) {
171
199
  return;
@@ -191,11 +219,20 @@ export class Input {
191
219
  this._pollCounter = 0;
192
220
  }
193
221
 
222
+ /**
223
+ * TBD.
224
+ * @param {number} x - TBD.
225
+ * @param {number} y - TBD.
226
+ */
194
227
  resetSpeed(x, y) {
195
228
  this._oldPosition.setTo(x, y);
196
229
  this.speed.setTo(0, 0);
197
230
  }
198
231
 
232
+ /**
233
+ * TBD.
234
+ * @param event
235
+ */
199
236
  startPointer(event) {
200
237
  if (this.maxPointers >= 0 && this.countActivePointers(this.maxPointers) >= this.maxPointers) {
201
238
  return null;
@@ -215,6 +252,10 @@ export class Input {
215
252
  return null;
216
253
  }
217
254
 
255
+ /**
256
+ * TBD.
257
+ * @param event
258
+ */
218
259
  updatePointer(event) {
219
260
  if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
220
261
  return this.pointer1.move(event);
@@ -231,6 +272,10 @@ export class Input {
231
272
  return null;
232
273
  }
233
274
 
275
+ /**
276
+ * TBD.
277
+ * @param event
278
+ */
234
279
  stopPointer(event) {
235
280
  if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
236
281
  return this.pointer1.stop(event);
@@ -247,6 +292,10 @@ export class Input {
247
292
  return null;
248
293
  }
249
294
 
295
+ /**
296
+ * TBD.
297
+ * @param limit
298
+ */
250
299
  countActivePointers(limit = this.pointers.length) {
251
300
  let count = limit;
252
301
  for (let i = 0; i < this.pointers.length && count > 0; i += 1) {
@@ -258,6 +307,10 @@ export class Input {
258
307
  return limit - count;
259
308
  }
260
309
 
310
+ /**
311
+ * TBD.
312
+ * @param isActive
313
+ */
261
314
  getPointer(isActive = false) {
262
315
  for (let i = 0; i < this.pointers.length; i += 1) {
263
316
  const pointer = this.pointers[i];
@@ -268,6 +321,10 @@ export class Input {
268
321
  return null;
269
322
  }
270
323
 
324
+ /**
325
+ * TBD.
326
+ * @param identifier
327
+ */
271
328
  getPointerFromIdentifier(identifier) {
272
329
  for (let i = 0; i < this.pointers.length; i += 1) {
273
330
  const pointer = this.pointers[i];
@@ -279,6 +336,10 @@ export class Input {
279
336
  return null;
280
337
  }
281
338
 
339
+ /**
340
+ * TBD.
341
+ * @param pointerId
342
+ */
282
343
  getPointerFromId(pointerId) {
283
344
  for (let i = 0; i < this.pointers.length; i += 1) {
284
345
  const pointer = this.pointers[i];
@@ -290,6 +351,12 @@ export class Input {
290
351
  return null;
291
352
  }
292
353
 
354
+ /**
355
+ * TBD.
356
+ * @param displayObject
357
+ * @param pointer
358
+ * @param output
359
+ */
293
360
  getLocalPosition(displayObject, pointer, output = null) {
294
361
  const result = output || new Point();
295
362
  const wt = displayObject.worldTransform;
@@ -300,6 +367,12 @@ export class Input {
300
367
  );
301
368
  }
302
369
 
370
+ /**
371
+ * TBD.
372
+ * @param displayObject
373
+ * @param pointer
374
+ * @param localPoint
375
+ */
303
376
  hitTest(displayObject, pointer, localPoint) {
304
377
  if (!displayObject.worldVisible) {
305
378
  return false;
@@ -321,11 +394,7 @@ export class Input {
321
394
  } else if (displayObject instanceof Graphics) {
322
395
  for (let i = 0; i < displayObject.graphicsData.length; i += 1) {
323
396
  const data = displayObject.graphicsData[i];
324
- if (
325
- data.fill &&
326
- data.shape &&
327
- data.shape.contains(this._localPoint.x, this._localPoint.y)
328
- ) {
397
+ if (data.fill && data.shape && data.shape.contains(this._localPoint.x, this._localPoint.y)) {
329
398
  // Only deal with fills..
330
399
  return true;
331
400
  }
@@ -340,42 +409,72 @@ export class Input {
340
409
  return false;
341
410
  }
342
411
 
412
+ /**
413
+ * TBD.
414
+ */
343
415
  onClickTrampoline() {
344
416
  this.activePointer.processClickTrampolines();
345
417
  }
346
418
 
419
+ /**
420
+ * TBD.
421
+ */
347
422
  get x() {
348
423
  return this._x;
349
424
  }
350
425
 
426
+ /**
427
+ * TBD.
428
+ */
351
429
  set x(value) {
352
430
  this._x = Math.floor(value);
353
431
  }
354
432
 
433
+ /**
434
+ * TBD.
435
+ */
355
436
  get y() {
356
437
  return this._y;
357
438
  }
358
439
 
440
+ /**
441
+ * TBD.
442
+ */
359
443
  set y(value) {
360
444
  this._y = Math.floor(value);
361
445
  }
362
446
 
447
+ /**
448
+ * TBD.
449
+ */
363
450
  get pollLocked() {
364
451
  return this.pollRate > 0 && this._pollCounter < this.pollRate;
365
452
  }
366
453
 
454
+ /**
455
+ * TBD.
456
+ */
367
457
  get totalInactivePointers() {
368
458
  return this.pointers.length - this.countActivePointers();
369
459
  }
370
460
 
461
+ /**
462
+ * TBD.
463
+ */
371
464
  get totalActivePointers() {
372
465
  return this.countActivePointers();
373
466
  }
374
467
 
468
+ /**
469
+ * TBD.
470
+ */
375
471
  get worldX() {
376
472
  return this.x;
377
473
  }
378
474
 
475
+ /**
476
+ * TBD.
477
+ */
379
478
  get worldY() {
380
479
  return this.y;
381
480
  }