@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,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,45 @@ export class Input {
116
122
  this.game.canvas.removeEventListener('click', this._onClickTrampoline);
117
123
  }
118
124
 
125
+ /**
126
+ * TBD.
127
+ * @param {Function} callback - TBD.
128
+ * @param context - TBD.
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 {Function} callback - TBD.
138
+ * @param context - TBD.
139
+ */
124
140
  addMoveCallback(callback, context) {
125
141
  this.moveCallbacks.push({ callback, context });
126
142
  }
127
143
 
144
+ /**
145
+ * TBD.
146
+ * @param {Function} callback - TBD.
147
+ * @param context - TBD.
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
+ * @returns {Pointer} TBD.
163
+ */
142
164
  addPointer() {
143
165
  if (this.pointers.length >= MAX_POINTERS) {
144
166
  console.warn('Input.addPointer: Maximum limit of ' + MAX_POINTERS + ' pointers reached.');
@@ -151,6 +173,9 @@ export class Input {
151
173
  return pointer;
152
174
  }
153
175
 
176
+ /**
177
+ * TBD.
178
+ */
154
179
  update() {
155
180
  if (this.pollRate > 0 && this._pollCounter < this.pollRate) {
156
181
  this._pollCounter += 1;
@@ -166,6 +191,10 @@ export class Input {
166
191
  this._pollCounter = 0;
167
192
  }
168
193
 
194
+ /**
195
+ * TBD.
196
+ * @param {boolean} hard - TBD.
197
+ */
169
198
  reset(hard = false) {
170
199
  if (!this.game.isBooted || this.resetLocked) {
171
200
  return;
@@ -191,11 +220,21 @@ export class Input {
191
220
  this._pollCounter = 0;
192
221
  }
193
222
 
223
+ /**
224
+ * TBD.
225
+ * @param {number} x - TBD.
226
+ * @param {number} y - TBD.
227
+ */
194
228
  resetSpeed(x, y) {
195
229
  this._oldPosition.setTo(x, y);
196
230
  this.speed.setTo(0, 0);
197
231
  }
198
232
 
233
+ /**
234
+ * TBD.
235
+ * @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
236
+ * @returns {Pointer} TBD.
237
+ */
199
238
  startPointer(event) {
200
239
  if (this.maxPointers >= 0 && this.countActivePointers(this.maxPointers) >= this.maxPointers) {
201
240
  return null;
@@ -215,6 +254,11 @@ export class Input {
215
254
  return null;
216
255
  }
217
256
 
257
+ /**
258
+ * TBD.
259
+ * @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
260
+ * @returns {Pointer} TBD.
261
+ */
218
262
  updatePointer(event) {
219
263
  if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
220
264
  return this.pointer1.move(event);
@@ -231,6 +275,11 @@ export class Input {
231
275
  return null;
232
276
  }
233
277
 
278
+ /**
279
+ * TBD.
280
+ * @param {MouseEvent|TouchEvent|PointerEvent} event - TBD.
281
+ * @returns {Pointer} TBD.
282
+ */
234
283
  stopPointer(event) {
235
284
  if (this.pointer1.active && this.pointer1.identifier === event.identifier) {
236
285
  return this.pointer1.stop(event);
@@ -247,6 +296,11 @@ export class Input {
247
296
  return null;
248
297
  }
249
298
 
299
+ /**
300
+ * TBD.
301
+ * @param limit - TBD.
302
+ * @returns {number} TBD.
303
+ */
250
304
  countActivePointers(limit = this.pointers.length) {
251
305
  let count = limit;
252
306
  for (let i = 0; i < this.pointers.length && count > 0; i += 1) {
@@ -258,6 +312,11 @@ export class Input {
258
312
  return limit - count;
259
313
  }
260
314
 
315
+ /**
316
+ * TBD.
317
+ * @param {boolean} isActive - TBD.
318
+ * @returns {Pointer} TBD.
319
+ */
261
320
  getPointer(isActive = false) {
262
321
  for (let i = 0; i < this.pointers.length; i += 1) {
263
322
  const pointer = this.pointers[i];
@@ -268,6 +327,11 @@ export class Input {
268
327
  return null;
269
328
  }
270
329
 
330
+ /**
331
+ * TBD.
332
+ * @param identifier - TBD.
333
+ * @returns {Pointer} TBD.
334
+ */
271
335
  getPointerFromIdentifier(identifier) {
272
336
  for (let i = 0; i < this.pointers.length; i += 1) {
273
337
  const pointer = this.pointers[i];
@@ -279,6 +343,11 @@ export class Input {
279
343
  return null;
280
344
  }
281
345
 
346
+ /**
347
+ * TBD.
348
+ * @param pointerId - TBD.
349
+ * @returns {Pointer} TBD.
350
+ */
282
351
  getPointerFromId(pointerId) {
283
352
  for (let i = 0; i < this.pointers.length; i += 1) {
284
353
  const pointer = this.pointers[i];
@@ -290,6 +359,13 @@ export class Input {
290
359
  return null;
291
360
  }
292
361
 
362
+ /**
363
+ * TBD.
364
+ * @param displayObject - TBD.
365
+ * @param pointer - TBD.
366
+ * @param output - TBD.
367
+ * @returns {Point} TBD.
368
+ */
293
369
  getLocalPosition(displayObject, pointer, output = null) {
294
370
  const result = output || new Point();
295
371
  const wt = displayObject.worldTransform;
@@ -300,6 +376,13 @@ export class Input {
300
376
  );
301
377
  }
302
378
 
379
+ /**
380
+ * TBD.
381
+ * @param displayObject - TBD.
382
+ * @param pointer - TBD.
383
+ * @param localPoint - TBD.
384
+ * @returns {boolean} TBD.
385
+ */
303
386
  hitTest(displayObject, pointer, localPoint) {
304
387
  if (!displayObject.worldVisible) {
305
388
  return false;
@@ -321,11 +404,7 @@ export class Input {
321
404
  } else if (displayObject instanceof Graphics) {
322
405
  for (let i = 0; i < displayObject.graphicsData.length; i += 1) {
323
406
  const data = displayObject.graphicsData[i];
324
- if (
325
- data.fill &&
326
- data.shape &&
327
- data.shape.contains(this._localPoint.x, this._localPoint.y)
328
- ) {
407
+ if (data.fill && data.shape && data.shape.contains(this._localPoint.x, this._localPoint.y)) {
329
408
  // Only deal with fills..
330
409
  return true;
331
410
  }
@@ -340,42 +419,79 @@ export class Input {
340
419
  return false;
341
420
  }
342
421
 
422
+ /**
423
+ * TBD.
424
+ */
343
425
  onClickTrampoline() {
344
426
  this.activePointer.processClickTrampolines();
345
427
  }
346
428
 
429
+ /**
430
+ * TBD.
431
+ * @returns {number} TBD.
432
+ */
347
433
  get x() {
348
434
  return this._x;
349
435
  }
350
436
 
437
+ /**
438
+ * TBD.
439
+ */
351
440
  set x(value) {
352
441
  this._x = Math.floor(value);
353
442
  }
354
443
 
444
+ /**
445
+ * TBD.
446
+ * @returns {number} TBD.
447
+ */
355
448
  get y() {
356
449
  return this._y;
357
450
  }
358
451
 
452
+ /**
453
+ * TBD.
454
+ */
359
455
  set y(value) {
360
456
  this._y = Math.floor(value);
361
457
  }
362
458
 
459
+ /**
460
+ * TBD.
461
+ * @returns {boolean} TBD.
462
+ */
363
463
  get pollLocked() {
364
464
  return this.pollRate > 0 && this._pollCounter < this.pollRate;
365
465
  }
366
466
 
467
+ /**
468
+ * TBD.
469
+ * @returns {number} TBD.
470
+ */
367
471
  get totalInactivePointers() {
368
472
  return this.pointers.length - this.countActivePointers();
369
473
  }
370
474
 
475
+ /**
476
+ * TBD.
477
+ * @returns {number} TBD.
478
+ */
371
479
  get totalActivePointers() {
372
480
  return this.countActivePointers();
373
481
  }
374
482
 
483
+ /**
484
+ * TBD.
485
+ * @returns {number} TBD.
486
+ */
375
487
  get worldX() {
376
488
  return this.x;
377
489
  }
378
490
 
491
+ /**
492
+ * TBD.
493
+ * @returns {number} TBD.
494
+ */
379
495
  get worldY() {
380
496
  return this.y;
381
497
  }