@vpmedia/phaser 1.16.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 (74) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/phaser/core/animation.js +28 -16
  4. package/src/phaser/core/animation_manager.js +34 -20
  5. package/src/phaser/core/animation_parser.js +1 -1
  6. package/src/phaser/core/array_set.js +17 -9
  7. package/src/phaser/core/cache.js +61 -45
  8. package/src/phaser/core/factory.js +10 -10
  9. package/src/phaser/core/frame_data.js +1 -1
  10. package/src/phaser/core/input.js +37 -20
  11. package/src/phaser/core/input_handler.js +1 -1
  12. package/src/phaser/core/input_mouse.js +16 -12
  13. package/src/phaser/core/input_mspointer.js +7 -7
  14. package/src/phaser/core/input_pointer.js +26 -17
  15. package/src/phaser/core/input_touch.js +7 -7
  16. package/src/phaser/core/loader.js +104 -75
  17. package/src/phaser/core/raf.js +1 -1
  18. package/src/phaser/core/scale_manager.js +27 -27
  19. package/src/phaser/core/scene_manager.js +9 -9
  20. package/src/phaser/core/sound.js +3 -3
  21. package/src/phaser/core/sound_manager.js +8 -8
  22. package/src/phaser/core/sound_sprite.js +3 -3
  23. package/src/phaser/core/timer.js +9 -9
  24. package/src/phaser/core/timer_event.js +2 -2
  25. package/src/phaser/core/tween.js +1 -1
  26. package/src/phaser/display/group.js +28 -20
  27. package/src/phaser/display/image.js +3 -1
  28. package/types/phaser/core/animation.d.ts +38 -26
  29. package/types/phaser/core/animation.d.ts.map +1 -1
  30. package/types/phaser/core/animation_manager.d.ts +54 -39
  31. package/types/phaser/core/animation_manager.d.ts.map +1 -1
  32. package/types/phaser/core/animation_parser.d.ts +2 -2
  33. package/types/phaser/core/array_set.d.ts +24 -16
  34. package/types/phaser/core/array_set.d.ts.map +1 -1
  35. package/types/phaser/core/cache.d.ts +79 -73
  36. package/types/phaser/core/cache.d.ts.map +1 -1
  37. package/types/phaser/core/factory.d.ts +17 -17
  38. package/types/phaser/core/factory.d.ts.map +1 -1
  39. package/types/phaser/core/frame_data.d.ts +2 -2
  40. package/types/phaser/core/frame_data.d.ts.map +1 -1
  41. package/types/phaser/core/input.d.ts +49 -32
  42. package/types/phaser/core/input.d.ts.map +1 -1
  43. package/types/phaser/core/input_handler.d.ts +2 -2
  44. package/types/phaser/core/input_handler.d.ts.map +1 -1
  45. package/types/phaser/core/input_mouse.d.ts +20 -19
  46. package/types/phaser/core/input_mouse.d.ts.map +1 -1
  47. package/types/phaser/core/input_mspointer.d.ts +15 -15
  48. package/types/phaser/core/input_mspointer.d.ts.map +1 -1
  49. package/types/phaser/core/input_pointer.d.ts +39 -30
  50. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  51. package/types/phaser/core/input_touch.d.ts +15 -15
  52. package/types/phaser/core/input_touch.d.ts.map +1 -1
  53. package/types/phaser/core/loader.d.ts +118 -92
  54. package/types/phaser/core/loader.d.ts.map +1 -1
  55. package/types/phaser/core/raf.d.ts +3 -3
  56. package/types/phaser/core/raf.d.ts.map +1 -1
  57. package/types/phaser/core/scale_manager.d.ts +34 -34
  58. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  59. package/types/phaser/core/scene_manager.d.ts +9 -9
  60. package/types/phaser/core/sound.d.ts +4 -4
  61. package/types/phaser/core/sound.d.ts.map +1 -1
  62. package/types/phaser/core/sound_manager.d.ts +12 -12
  63. package/types/phaser/core/sound_manager.d.ts.map +1 -1
  64. package/types/phaser/core/sound_sprite.d.ts +3 -3
  65. package/types/phaser/core/timer.d.ts +14 -14
  66. package/types/phaser/core/timer.d.ts.map +1 -1
  67. package/types/phaser/core/timer_event.d.ts +4 -4
  68. package/types/phaser/core/timer_event.d.ts.map +1 -1
  69. package/types/phaser/core/tween.d.ts +3 -3
  70. package/types/phaser/core/tween.d.ts.map +1 -1
  71. package/types/phaser/display/group.d.ts +38 -30
  72. package/types/phaser/display/group.d.ts.map +1 -1
  73. package/types/phaser/display/image.d.ts +7 -5
  74. package/types/phaser/display/image.d.ts.map +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vpmedia/phaser
2
2
 
3
- [![npm version](https://badge.fury.io/js/@vpmedia%2Fphaser.svg?v=1.16.0)](https://badge.fury.io/js/@vpmedia%2Fphaser)
3
+ [![npm version](https://badge.fury.io/js/@vpmedia%2Fphaser.svg?v=1.17.0)](https://badge.fury.io/js/@vpmedia%2Fphaser)
4
4
  [![Node.js CI](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml/badge.svg)](https://github.com/vpmedia/phaser/actions/workflows/node.js.yml)
5
5
 
6
6
  @vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpmedia/phaser",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
5
5
  "author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
6
6
  "license": "MIT",
@@ -1,16 +1,17 @@
1
1
  import { Game } from './game';
2
2
  import { Signal } from './signal';
3
+ import { FrameData } from './frame_data';
3
4
 
4
5
  export class Animation {
5
6
  /**
6
7
  * TBD.
7
8
  * @param {Game} game - TBD.
8
9
  * @param parent - TBD.
9
- * @param name - TBD.
10
- * @param frameData - TBD.
10
+ * @param {string} name - TBD.
11
+ * @param {FrameData} frameData - TBD.
11
12
  * @param frames - TBD.
12
- * @param frameRate - TBD.
13
- * @param loop - TBD.
13
+ * @param {number} frameRate - TBD.
14
+ * @param {boolean} loop - TBD.
14
15
  */
15
16
  constructor(game, parent, name, frameData, frames, frameRate, loop = false) {
16
17
  this.game = game;
@@ -43,9 +44,10 @@ export class Animation {
43
44
 
44
45
  /**
45
46
  * TBD.
46
- * @param frameRate - TBD.
47
- * @param loop - TBD.
48
- * @param killOnComplete - TBD.
47
+ * @param {number} frameRate - TBD.
48
+ * @param {boolean} loop - TBD.
49
+ * @param {boolean} killOnComplete - TBD.
50
+ * @returns {Animation} TBD.
49
51
  */
50
52
  play(frameRate, loop, killOnComplete) {
51
53
  if (typeof frameRate === 'number') {
@@ -95,6 +97,7 @@ export class Animation {
95
97
 
96
98
  /**
97
99
  * TBD.
100
+ * @returns {Animation} TBD.
98
101
  */
99
102
  reverse() {
100
103
  this.reversed = !this.reversed;
@@ -103,6 +106,7 @@ export class Animation {
103
106
 
104
107
  /**
105
108
  * TBD.
109
+ * @returns {Animation} TBD.
106
110
  */
107
111
  reverseOnce() {
108
112
  this.onComplete.addOnce(this.reverse, this);
@@ -111,8 +115,8 @@ export class Animation {
111
115
 
112
116
  /**
113
117
  * TBD.
114
- * @param frameId - TBD.
115
- * @param useLocalFrameIndex - TBD.
118
+ * @param {number|string} frameId - TBD.
119
+ * @param {boolean} useLocalFrameIndex - TBD.
116
120
  */
117
121
  setFrame(frameId, useLocalFrameIndex = false) {
118
122
  let frameIndex;
@@ -145,8 +149,8 @@ export class Animation {
145
149
 
146
150
  /**
147
151
  * TBD.
148
- * @param resetFrame - TBD.
149
- * @param dispatchComplete - TBD.
152
+ * @param {boolean} resetFrame - TBD.
153
+ * @param {boolean} dispatchComplete - TBD.
150
154
  */
151
155
  stop(resetFrame = false, dispatchComplete = false) {
152
156
  this.isPlaying = false;
@@ -184,6 +188,7 @@ export class Animation {
184
188
 
185
189
  /**
186
190
  * TBD.
191
+ * @returns {boolean} TBD.
187
192
  */
188
193
  update() {
189
194
  if (this.isPaused) {
@@ -242,8 +247,9 @@ export class Animation {
242
247
 
243
248
  /**
244
249
  * TBD.
245
- * @param signalUpdate - TBD.
246
- * @param fromPlay - TBD.
250
+ * @param {boolean} signalUpdate - TBD.
251
+ * @param {boolean} fromPlay - TBD.
252
+ * @returns {boolean} TBD.
247
253
  */
248
254
  updateCurrentFrame(signalUpdate, fromPlay = false) {
249
255
  if (!this._frameData || !this.currentFrame) {
@@ -266,7 +272,7 @@ export class Animation {
266
272
 
267
273
  /**
268
274
  * TBD.
269
- * @param quantity - TBD.
275
+ * @param {number} quantity - TBD.
270
276
  */
271
277
  next(quantity = 1) {
272
278
  let frame = this._frameIndex + quantity;
@@ -285,7 +291,7 @@ export class Animation {
285
291
 
286
292
  /**
287
293
  * TBD.
288
- * @param quantity - TBD.
294
+ * @param {number} quantity - TBD.
289
295
  */
290
296
  previous(quantity = 1) {
291
297
  let frame = this._frameIndex - quantity;
@@ -304,7 +310,7 @@ export class Animation {
304
310
 
305
311
  /**
306
312
  * TBD.
307
- * @param frameData - TBD.
313
+ * @param {FrameData} frameData - TBD.
308
314
  */
309
315
  updateFrameData(frameData) {
310
316
  this._frameData = frameData;
@@ -355,6 +361,7 @@ export class Animation {
355
361
 
356
362
  /**
357
363
  * TBD.
364
+ * @returns {boolean} TBD.
358
365
  */
359
366
  get paused() {
360
367
  return this.isPaused;
@@ -374,6 +381,7 @@ export class Animation {
374
381
 
375
382
  /**
376
383
  * TBD.
384
+ * @returns {boolean} TBD.
377
385
  */
378
386
  get reversed() {
379
387
  return this.isReversed;
@@ -388,6 +396,7 @@ export class Animation {
388
396
 
389
397
  /**
390
398
  * TBD.
399
+ * @returns {number} TBD.
391
400
  */
392
401
  get frameTotal() {
393
402
  return this._frames.length;
@@ -395,6 +404,7 @@ export class Animation {
395
404
 
396
405
  /**
397
406
  * TBD.
407
+ * @returns {number} TBD.
398
408
  */
399
409
  get frame() {
400
410
  if (this.currentFrame !== null) {
@@ -419,6 +429,7 @@ export class Animation {
419
429
 
420
430
  /**
421
431
  * TBD.
432
+ * @returns {number} TBD.
422
433
  */
423
434
  get speed() {
424
435
  return 1000 / this.delay;
@@ -435,6 +446,7 @@ export class Animation {
435
446
 
436
447
  /**
437
448
  * TBD.
449
+ * @returns {boolean} TBD.
438
450
  */
439
451
  get enableUpdate() {
440
452
  return this.onUpdate !== null;
@@ -1,4 +1,5 @@
1
1
  import { Animation } from './animation';
2
+ import { FrameData } from './frame_data';
2
3
 
3
4
  export class AnimationManager {
4
5
  /**
@@ -36,8 +37,9 @@ export class AnimationManager {
36
37
 
37
38
  /**
38
39
  * TBD.
39
- * @param frameData - TBD.
40
- * @param frame - TBD.
40
+ * @param {FrameData} frameData - TBD.
41
+ * @param {number|string} frame - TBD.
42
+ * @returns {boolean} TBD.
41
43
  */
42
44
  loadFrameData(frameData, frame) {
43
45
  if (!frameData) {
@@ -65,8 +67,9 @@ export class AnimationManager {
65
67
 
66
68
  /**
67
69
  * TBD.
68
- * @param frameData - TBD.
69
- * @param frame - TBD.
70
+ * @param {FrameData} frameData - TBD.
71
+ * @param {number|string} frame - TBD.
72
+ * @returns {boolean} TBD.
70
73
  */
71
74
  copyFrameData(frameData, frame) {
72
75
  this._frameData = frameData.clone();
@@ -91,11 +94,12 @@ export class AnimationManager {
91
94
 
92
95
  /**
93
96
  * TBD.
94
- * @param name - TBD.
95
- * @param frameList - TBD.
96
- * @param frameRate - TBD.
97
- * @param loop - TBD.
98
- * @param useNumericIndex - TBD.
97
+ * @param {string} name - TBD.
98
+ * @param {number[]|string[]} frameList - TBD.
99
+ * @param {number} frameRate - TBD.
100
+ * @param {boolean} loop - TBD.
101
+ * @param {boolean} useNumericIndex - TBD.
102
+ * @returns {Animation} TBD.
99
103
  */
100
104
  add(name, frameList, frameRate = 60, loop = false, useNumericIndex = undefined) {
101
105
  const frames = frameList || [];
@@ -127,8 +131,9 @@ export class AnimationManager {
127
131
 
128
132
  /**
129
133
  * TBD.
130
- * @param frames - TBD.
131
- * @param useNumericIndex - TBD.
134
+ * @param {number[]} frames - TBD.
135
+ * @param {boolean} useNumericIndex - TBD.
136
+ * @returns {boolean} TBD.
132
137
  */
133
138
  validateFrames(frames, useNumericIndex = false) {
134
139
  for (let i = 0; i < frames.length; i += 1) {
@@ -145,10 +150,11 @@ export class AnimationManager {
145
150
 
146
151
  /**
147
152
  * TBD.
148
- * @param name - TBD.
149
- * @param frameRate - TBD.
150
- * @param loop - TBD.
151
- * @param killOnComplete - TBD.
153
+ * @param {string} name - TBD.
154
+ * @param {number} frameRate - TBD.
155
+ * @param {boolean} loop - TBD.
156
+ * @param {boolean} killOnComplete - TBD.
157
+ * @returns {Animation} TBD.
152
158
  */
153
159
  play(name, frameRate, loop, killOnComplete) {
154
160
  if (this._anims[name]) {
@@ -172,8 +178,8 @@ export class AnimationManager {
172
178
 
173
179
  /**
174
180
  * TBD.
175
- * @param name - TBD.
176
- * @param resetFrame - TBD.
181
+ * @param {string} name - TBD.
182
+ * @param {boolean} resetFrame - TBD.
177
183
  */
178
184
  stop(name, resetFrame = false) {
179
185
  if (this.currentAnim && (typeof name !== 'string' || name === this.currentAnim.name)) {
@@ -183,6 +189,7 @@ export class AnimationManager {
183
189
 
184
190
  /**
185
191
  * TBD.
192
+ * @returns {boolean} TBD.
186
193
  */
187
194
  update() {
188
195
  if (this.updateIfVisible && !this.sprite.visible) {
@@ -197,7 +204,7 @@ export class AnimationManager {
197
204
 
198
205
  /**
199
206
  * TBD.
200
- * @param quantity - TBD.
207
+ * @param {number} quantity - TBD.
201
208
  */
202
209
  next(quantity) {
203
210
  if (this.currentAnim) {
@@ -208,7 +215,7 @@ export class AnimationManager {
208
215
 
209
216
  /**
210
217
  * TBD.
211
- * @param quantity - TBD.
218
+ * @param {number} quantity - TBD.
212
219
  */
213
220
  previous(quantity) {
214
221
  if (this.currentAnim) {
@@ -219,7 +226,8 @@ export class AnimationManager {
219
226
 
220
227
  /**
221
228
  * TBD.
222
- * @param name - TBD.
229
+ * @param {string} name - TBD.
230
+ * @returns {Animation} TBD.
223
231
  */
224
232
  getAnimation(name) {
225
233
  if (name && this._anims[name]) {
@@ -239,6 +247,7 @@ export class AnimationManager {
239
247
 
240
248
  /**
241
249
  * TBD.
250
+ * @returns {FrameData} TBD.
242
251
  */
243
252
  get frameData() {
244
253
  return this._frameData;
@@ -246,6 +255,7 @@ export class AnimationManager {
246
255
 
247
256
  /**
248
257
  * TBD.
258
+ * @returns {number} TBD.
249
259
  */
250
260
  get frameTotal() {
251
261
  return this._frameData.total;
@@ -253,6 +263,7 @@ export class AnimationManager {
253
263
 
254
264
  /**
255
265
  * TBD.
266
+ * @returns {boolean} TBD.
256
267
  */
257
268
  get paused() {
258
269
  return this.currentAnim.isPaused;
@@ -267,6 +278,7 @@ export class AnimationManager {
267
278
 
268
279
  /**
269
280
  * TBD.
281
+ * @returns {string} TBD.
270
282
  */
271
283
  get name() {
272
284
  if (this.currentAnim) {
@@ -277,6 +289,7 @@ export class AnimationManager {
277
289
 
278
290
  /**
279
291
  * TBD.
292
+ * @returns {number} TBD.
280
293
  */
281
294
  get frame() {
282
295
  if (this.currentFrame) {
@@ -301,6 +314,7 @@ export class AnimationManager {
301
314
 
302
315
  /**
303
316
  * TBD.
317
+ * @returns {string} TBD.
304
318
  */
305
319
  get frameName() {
306
320
  if (this.currentFrame) {
@@ -5,7 +5,7 @@ import { Game } from './game';
5
5
  /**
6
6
  * TBD.
7
7
  * @param {Game} game - TBD.
8
- * @param {object} key - TBD.
8
+ * @param {string} key - TBD.
9
9
  * @param {number} frameWidth - TBD.
10
10
  * @param {number} frameHeight - TBD.
11
11
  * @param {number} frameMax - TBD.
@@ -1,7 +1,7 @@
1
1
  export class ArraySet {
2
2
  /**
3
3
  * TBD.
4
- * @param list - TBD.
4
+ * @param {object[]} list - TBD.
5
5
  */
6
6
  constructor(list = []) {
7
7
  this.position = 0;
@@ -10,7 +10,8 @@ export class ArraySet {
10
10
 
11
11
  /**
12
12
  * TBD.
13
- * @param item - TBD.
13
+ * @param {object} item - TBD.
14
+ * @returns {object} TBD.
14
15
  */
15
16
  add(item) {
16
17
  if (!this.exists(item)) {
@@ -21,7 +22,8 @@ export class ArraySet {
21
22
 
22
23
  /**
23
24
  * TBD.
24
- * @param item - TBD.
25
+ * @param {object} item - TBD.
26
+ * @returns {number} TBD.
25
27
  */
26
28
  getIndex(item) {
27
29
  return this.list.indexOf(item);
@@ -29,8 +31,9 @@ export class ArraySet {
29
31
 
30
32
  /**
31
33
  * TBD.
32
- * @param property - TBD.
33
- * @param value - TBD.
34
+ * @param {string} property - TBD.
35
+ * @param {object} value - TBD.
36
+ * @returns {object} TBD.
34
37
  */
35
38
  getByKey(property, value) {
36
39
  let i = this.list.length;
@@ -45,7 +48,8 @@ export class ArraySet {
45
48
 
46
49
  /**
47
50
  * TBD.
48
- * @param item - TBD.
51
+ * @param {object} item - TBD.
52
+ * @returns {boolean} TBD.
49
53
  */
50
54
  exists(item) {
51
55
  return this.list.indexOf(item) > -1;
@@ -60,7 +64,8 @@ export class ArraySet {
60
64
 
61
65
  /**
62
66
  * TBD.
63
- * @param item - TBD.
67
+ * @param {object} item - TBD.
68
+ * @returns {object} TBD.
64
69
  */
65
70
  remove(item) {
66
71
  const idx = this.list.indexOf(item);
@@ -74,7 +79,7 @@ export class ArraySet {
74
79
  /**
75
80
  * TBD.
76
81
  * @param {string} key - TBD.
77
- * @param value - TBD.
82
+ * @param {object} value - TBD.
78
83
  */
79
84
  setAll(key, value) {
80
85
  let i = this.list.length;
@@ -103,7 +108,7 @@ export class ArraySet {
103
108
 
104
109
  /**
105
110
  * TBD.
106
- * @param destroy - TBD.
111
+ * @param {boolean} destroy - TBD.
107
112
  */
108
113
  removeAll(destroy = false) {
109
114
  let i = this.list.length;
@@ -122,6 +127,7 @@ export class ArraySet {
122
127
 
123
128
  /**
124
129
  * TBD.
130
+ * @returns {number} TBD.
125
131
  */
126
132
  get total() {
127
133
  return this.list.length;
@@ -129,6 +135,7 @@ export class ArraySet {
129
135
 
130
136
  /**
131
137
  * TBD.
138
+ * @returns {object} TBD.
132
139
  */
133
140
  get first() {
134
141
  this.position = 0;
@@ -140,6 +147,7 @@ export class ArraySet {
140
147
 
141
148
  /**
142
149
  * TBD.
150
+ * @returns {object} TBD.
143
151
  */
144
152
  get next() {
145
153
  if (this.position < this.list.length) {