melonjs 10.1.1 → 10.2.3

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 (92) hide show
  1. package/README.md +6 -10
  2. package/dist/melonjs.js +3114 -2866
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +2588 -2498
  5. package/dist/melonjs.module.js +2694 -2479
  6. package/package.json +10 -11
  7. package/src/audio/audio.js +43 -43
  8. package/src/camera/camera2d.js +52 -74
  9. package/src/entity/draggable.js +18 -17
  10. package/src/entity/droptarget.js +19 -18
  11. package/src/entity/entity.js +22 -26
  12. package/src/game.js +3 -3
  13. package/src/index.js +15 -11
  14. package/src/input/gamepad.js +13 -13
  15. package/src/input/input.js +1 -1
  16. package/src/input/keyboard.js +14 -16
  17. package/src/input/pointer.js +42 -35
  18. package/src/input/pointerevent.js +25 -33
  19. package/src/lang/deprecated.js +3 -3
  20. package/src/level/level.js +24 -16
  21. package/src/level/tiled/TMXGroup.js +6 -6
  22. package/src/level/tiled/TMXLayer.js +31 -31
  23. package/src/level/tiled/TMXObject.js +19 -19
  24. package/src/level/tiled/TMXTile.js +11 -12
  25. package/src/level/tiled/TMXTileMap.js +23 -21
  26. package/src/level/tiled/TMXTileset.js +13 -13
  27. package/src/level/tiled/TMXTilesetGroup.js +4 -4
  28. package/src/level/tiled/TMXUtils.js +13 -11
  29. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  30. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  31. package/src/level/tiled/renderer/TMXRenderer.js +17 -17
  32. package/src/loader/loader.js +31 -27
  33. package/src/loader/loadingscreen.js +44 -75
  34. package/src/math/color.js +45 -64
  35. package/src/math/math.js +17 -17
  36. package/src/math/matrix2.js +46 -46
  37. package/src/math/matrix3.js +64 -64
  38. package/src/math/observable_vector2.js +45 -57
  39. package/src/math/observable_vector3.js +56 -70
  40. package/src/math/vector2.js +60 -59
  41. package/src/math/vector3.js +65 -64
  42. package/src/particles/emitter.js +53 -55
  43. package/src/particles/particle.js +1 -1
  44. package/src/physics/body.js +45 -51
  45. package/src/physics/bounds.js +36 -36
  46. package/src/physics/collision.js +15 -16
  47. package/src/physics/detector.js +10 -11
  48. package/src/physics/quadtree.js +18 -16
  49. package/src/physics/sat.js +17 -17
  50. package/src/physics/world.js +12 -10
  51. package/src/plugin/plugin.js +6 -6
  52. package/src/renderable/GUI.js +13 -18
  53. package/src/renderable/collectable.js +3 -3
  54. package/src/renderable/colorlayer.js +4 -4
  55. package/src/renderable/container.js +64 -46
  56. package/src/renderable/imagelayer.js +30 -31
  57. package/src/renderable/nineslicesprite.js +158 -69
  58. package/src/renderable/renderable.js +68 -67
  59. package/src/renderable/sprite.js +57 -43
  60. package/src/renderable/trigger.js +14 -15
  61. package/src/shapes/ellipse.js +27 -26
  62. package/src/shapes/line.js +8 -7
  63. package/src/shapes/poly.js +33 -31
  64. package/src/shapes/rectangle.js +50 -96
  65. package/src/state/stage.js +8 -8
  66. package/src/state/state.js +56 -56
  67. package/src/system/device.js +97 -84
  68. package/src/system/event.js +72 -72
  69. package/src/system/pooling.js +14 -14
  70. package/src/system/save.js +6 -3
  71. package/src/system/timer.js +20 -20
  72. package/src/text/bitmaptext.js +27 -33
  73. package/src/text/bitmaptextdata.js +9 -9
  74. package/src/text/text.js +118 -59
  75. package/src/tweens/easing.js +4 -4
  76. package/src/tweens/interpolation.js +4 -4
  77. package/src/tweens/tween.js +37 -27
  78. package/src/utils/agent.js +9 -8
  79. package/src/utils/array.js +4 -4
  80. package/src/utils/file.js +4 -4
  81. package/src/utils/function.js +5 -5
  82. package/src/utils/string.js +12 -12
  83. package/src/utils/utils.js +19 -19
  84. package/src/video/canvas/canvas_renderer.js +90 -90
  85. package/src/video/renderer.js +40 -39
  86. package/src/video/texture.js +85 -76
  87. package/src/video/texture_cache.js +11 -0
  88. package/src/video/video.js +31 -31
  89. package/src/video/webgl/buffer/vertex.js +9 -1
  90. package/src/video/webgl/glshader.js +20 -20
  91. package/src/video/webgl/webgl_compositor.js +47 -46
  92. package/src/video/webgl/webgl_renderer.js +104 -104
@@ -7,8 +7,8 @@ import pool from "./../system/pooling.js";
7
7
  * @class Vector2d
8
8
  * @memberOf me
9
9
  * @constructor
10
- * @param {Number} [x=0] x value of the vector
11
- * @param {Number} [y=0] y value of the vector
10
+ * @param {number} [x=0] x value of the vector
11
+ * @param {number} [y=0] y value of the vector
12
12
  */
13
13
  class Vector2d {
14
14
 
@@ -27,7 +27,8 @@ class Vector2d {
27
27
  }
28
28
 
29
29
  /**
30
- * @ignore */
30
+ * @ignore
31
+ */
31
32
  _set(x, y) {
32
33
  this.x = x;
33
34
  this.y = y;
@@ -39,9 +40,9 @@ class Vector2d {
39
40
  * @name set
40
41
  * @memberOf me.Vector2d
41
42
  * @function
42
- * @param {Number} x
43
- * @param {Number} y
44
- * @return {me.Vector2d} Reference to this object for method chaining
43
+ * @param {number} x
44
+ * @param {number} y
45
+ * @returns {me.Vector2d} Reference to this object for method chaining
45
46
  */
46
47
  set(x, y) {
47
48
  if (x !== +x || y !== +y) {
@@ -53,7 +54,7 @@ class Vector2d {
53
54
  /**
54
55
  * x value of the vector
55
56
  * @public
56
- * @type Number
57
+ * @type {number}
57
58
  * @name x
58
59
  * @memberOf me.Vector2d
59
60
  */
@@ -62,7 +63,7 @@ class Vector2d {
62
63
  /**
63
64
  * y value of the vector
64
65
  * @public
65
- * @type Number
66
+ * @type {number}
66
67
  * @name y
67
68
  * @memberOf me.Vector2d
68
69
  */
@@ -76,7 +77,7 @@ class Vector2d {
76
77
  * @name setZero
77
78
  * @memberOf me.Vector2d
78
79
  * @function
79
- * @return {me.Vector2d} Reference to this object for method chaining
80
+ * @returns {me.Vector2d} Reference to this object for method chaining
80
81
  */
81
82
  setZero() {
82
83
  return this.set(0, 0);
@@ -88,7 +89,7 @@ class Vector2d {
88
89
  * @memberOf me.Vector2d
89
90
  * @function
90
91
  * @param {me.Vector2d} v
91
- * @return {me.Vector2d} Reference to this object for method chaining
92
+ * @returns {me.Vector2d} Reference to this object for method chaining
92
93
  */
93
94
  setV(v) {
94
95
  return this._set(v.x, v.y);
@@ -100,7 +101,7 @@ class Vector2d {
100
101
  * @memberOf me.Vector2d
101
102
  * @function
102
103
  * @param {me.Vector2d} v
103
- * @return {me.Vector2d} Reference to this object for method chaining
104
+ * @returns {me.Vector2d} Reference to this object for method chaining
104
105
  */
105
106
  add(v) {
106
107
  return this._set(this.x + v.x, this.y + v.y);
@@ -112,7 +113,7 @@ class Vector2d {
112
113
  * @memberOf me.Vector2d
113
114
  * @function
114
115
  * @param {me.Vector2d} v
115
- * @return {me.Vector2d} Reference to this object for method chaining
116
+ * @returns {me.Vector2d} Reference to this object for method chaining
116
117
  */
117
118
  sub(v) {
118
119
  return this._set(this.x - v.x, this.y - v.y);
@@ -123,9 +124,9 @@ class Vector2d {
123
124
  * @name scale
124
125
  * @memberOf me.Vector2d
125
126
  * @function
126
- * @param {Number} x
127
- * @param {Number} [y=x]
128
- * @return {me.Vector2d} Reference to this object for method chaining
127
+ * @param {number} x
128
+ * @param {number} [y=x]
129
+ * @returns {me.Vector2d} Reference to this object for method chaining
129
130
  */
130
131
  scale(x, y) {
131
132
  return this._set(this.x * x, this.y * (typeof (y) !== "undefined" ? y : x));
@@ -136,7 +137,7 @@ class Vector2d {
136
137
  * @name toIso
137
138
  * @memberOf me.Vector2d
138
139
  * @function
139
- * @return {me.Vector2d} Reference to this object for method chaining
140
+ * @returns {me.Vector2d} Reference to this object for method chaining
140
141
  */
141
142
  toIso() {
142
143
  return this._set(this.x - this.y, (this.x + this.y) * 0.5);
@@ -147,7 +148,7 @@ class Vector2d {
147
148
  * @name to2d
148
149
  * @memberOf me.Vector2d
149
150
  * @function
150
- * @return {me.Vector2d} Reference to this object for method chaining
151
+ * @returns {me.Vector2d} Reference to this object for method chaining
151
152
  */
152
153
  to2d() {
153
154
  return this._set(this.y + this.x / 2, this.y - this.x / 2);
@@ -159,7 +160,7 @@ class Vector2d {
159
160
  * @memberOf me.Vector2d
160
161
  * @function
161
162
  * @param {me.Vector2d} v
162
- * @return {me.Vector2d} Reference to this object for method chaining
163
+ * @returns {me.Vector2d} Reference to this object for method chaining
163
164
  */
164
165
  scaleV(v) {
165
166
  return this._set(this.x * v.x, this.y * v.y);
@@ -170,8 +171,8 @@ class Vector2d {
170
171
  * @name div
171
172
  * @memberOf me.Vector2d
172
173
  * @function
173
- * @param {Number} value
174
- * @return {me.Vector2d} Reference to this object for method chaining
174
+ * @param {number} n the value to divide the vector by
175
+ * @returns {me.Vector2d} Reference to this object for method chaining
175
176
  */
176
177
  div(n) {
177
178
  return this._set(this.x / n, this.y / n);
@@ -182,7 +183,7 @@ class Vector2d {
182
183
  * @name abs
183
184
  * @memberOf me.Vector2d
184
185
  * @function
185
- * @return {me.Vector2d} Reference to this object for method chaining
186
+ * @returns {me.Vector2d} Reference to this object for method chaining
186
187
  */
187
188
  abs() {
188
189
  return this._set((this.x < 0) ? -this.x : this.x, (this.y < 0) ? -this.y : this.y);
@@ -193,9 +194,9 @@ class Vector2d {
193
194
  * @name clamp
194
195
  * @memberOf me.Vector2d
195
196
  * @function
196
- * @param {Number} low
197
- * @param {Number} high
198
- * @return {me.Vector2d} new me.Vector2d
197
+ * @param {number} low
198
+ * @param {number} high
199
+ * @returns {me.Vector2d} new me.Vector2d
199
200
  */
200
201
  clamp(low, high) {
201
202
  return new Vector2d(clamp(this.x, low, high), clamp(this.y, low, high));
@@ -206,9 +207,9 @@ class Vector2d {
206
207
  * @name clampSelf
207
208
  * @memberOf me.Vector2d
208
209
  * @function
209
- * @param {Number} low
210
- * @param {Number} high
211
- * @return {me.Vector2d} Reference to this object for method chaining
210
+ * @param {number} low
211
+ * @param {number} high
212
+ * @returns {me.Vector2d} Reference to this object for method chaining
212
213
  */
213
214
  clampSelf(low, high) {
214
215
  return this._set(clamp(this.x, low, high), clamp(this.y, low, high));
@@ -220,7 +221,7 @@ class Vector2d {
220
221
  * @memberOf me.Vector2d
221
222
  * @function
222
223
  * @param {me.Vector2d} v
223
- * @return {me.Vector2d} Reference to this object for method chaining
224
+ * @returns {me.Vector2d} Reference to this object for method chaining
224
225
  */
225
226
  minV(v) {
226
227
  return this._set((this.x < v.x) ? this.x : v.x, (this.y < v.y) ? this.y : v.y);
@@ -232,7 +233,7 @@ class Vector2d {
232
233
  * @memberOf me.Vector2d
233
234
  * @function
234
235
  * @param {me.Vector2d} v
235
- * @return {me.Vector2d} Reference to this object for method chaining
236
+ * @returns {me.Vector2d} Reference to this object for method chaining
236
237
  */
237
238
  maxV(v) {
238
239
  return this._set((this.x > v.x) ? this.x : v.x, (this.y > v.y) ? this.y : v.y);
@@ -243,7 +244,7 @@ class Vector2d {
243
244
  * @name floor
244
245
  * @memberOf me.Vector2d
245
246
  * @function
246
- * @return {me.Vector2d} new me.Vector2d
247
+ * @returns {me.Vector2d} new me.Vector2d
247
248
  */
248
249
  floor() {
249
250
  return new Vector2d(Math.floor(this.x), Math.floor(this.y));
@@ -254,7 +255,7 @@ class Vector2d {
254
255
  * @name floorSelf
255
256
  * @memberOf me.Vector2d
256
257
  * @function
257
- * @return {me.Vector2d} Reference to this object for method chaining
258
+ * @returns {me.Vector2d} Reference to this object for method chaining
258
259
  */
259
260
  floorSelf() {
260
261
  return this._set(Math.floor(this.x), Math.floor(this.y));
@@ -265,7 +266,7 @@ class Vector2d {
265
266
  * @name ceil
266
267
  * @memberOf me.Vector2d
267
268
  * @function
268
- * @return {me.Vector2d} new me.Vector2d
269
+ * @returns {me.Vector2d} new me.Vector2d
269
270
  */
270
271
  ceil() {
271
272
  return new Vector2d(Math.ceil(this.x), Math.ceil(this.y));
@@ -276,7 +277,7 @@ class Vector2d {
276
277
  * @name ceilSelf
277
278
  * @memberOf me.Vector2d
278
279
  * @function
279
- * @return {me.Vector2d} Reference to this object for method chaining
280
+ * @returns {me.Vector2d} Reference to this object for method chaining
280
281
  */
281
282
  ceilSelf() {
282
283
  return this._set(Math.ceil(this.x), Math.ceil(this.y));
@@ -287,7 +288,7 @@ class Vector2d {
287
288
  * @name negate
288
289
  * @memberOf me.Vector2d
289
290
  * @function
290
- * @return {me.Vector2d} new me.Vector2d
291
+ * @returns {me.Vector2d} new me.Vector2d
291
292
  */
292
293
  negate() {
293
294
  return new Vector2d(-this.x, -this.y);
@@ -298,7 +299,7 @@ class Vector2d {
298
299
  * @name negateSelf
299
300
  * @memberOf me.Vector2d
300
301
  * @function
301
- * @return {me.Vector2d} Reference to this object for method chaining
302
+ * @returns {me.Vector2d} Reference to this object for method chaining
302
303
  */
303
304
  negateSelf() {
304
305
  return this._set(-this.x, -this.y);
@@ -310,7 +311,7 @@ class Vector2d {
310
311
  * @memberOf me.Vector2d
311
312
  * @function
312
313
  * @param {me.Vector2d} v
313
- * @return {me.Vector2d} Reference to this object for method chaining
314
+ * @returns {me.Vector2d} Reference to this object for method chaining
314
315
  */
315
316
  copy(v) {
316
317
  return this._set(v.x, v.y);
@@ -322,16 +323,16 @@ class Vector2d {
322
323
  * @memberOf me.Vector2d
323
324
  * @function
324
325
  * @param {me.Vector2d} v
325
- * @return {Boolean}
326
+ * @returns {boolean}
326
327
  */
327
328
  /**
328
329
  * return true if this vector is equal to the given values
329
330
  * @name equals
330
331
  * @memberOf me.Vector2d
331
332
  * @function
332
- * @param {Number} x
333
- * @param {Number} y
334
- * @return {Boolean}
333
+ * @param {number} x
334
+ * @param {number} y
335
+ * @returns {boolean}
335
336
  */
336
337
  equals() {
337
338
  var _x, _y;
@@ -352,7 +353,7 @@ class Vector2d {
352
353
  * @name normalize
353
354
  * @memberOf me.Vector2d
354
355
  * @function
355
- * @return {me.Vector2d} Reference to this object for method chaining
356
+ * @returns {me.Vector2d} Reference to this object for method chaining
356
357
  */
357
358
  normalize() {
358
359
  return this.div(this.length() || 1);
@@ -364,7 +365,7 @@ class Vector2d {
364
365
  * @name perp
365
366
  * @memberOf me.Vector2d
366
367
  * @function
367
- * @return {me.Vector2d} Reference to this object for method chaining
368
+ * @returns {me.Vector2d} Reference to this object for method chaining
368
369
  */
369
370
  perp() {
370
371
  return this._set(this.y, -this.x);
@@ -377,7 +378,7 @@ class Vector2d {
377
378
  * @function
378
379
  * @param {number} angle The angle to rotate (in radians)
379
380
  * @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
380
- * @return {me.Vector2d} Reference to this object for method chaining
381
+ * @returns {me.Vector2d} Reference to this object for method chaining
381
382
  */
382
383
  rotate(angle, v) {
383
384
  var cx = 0;
@@ -403,19 +404,19 @@ class Vector2d {
403
404
  * @memberOf me.Vector2d
404
405
  * @function
405
406
  * @param {me.Vector2d} v
406
- * @return {Number} The dot product.
407
+ * @returns {number} The dot product.
407
408
  */
408
409
  dotProduct(v) {
409
410
  return this.x * v.x + this.y * v.y;
410
411
  }
411
412
 
412
413
  /**
413
- * return the square length of this vector
414
- * @name length2
415
- * @memberOf me.Vector2d
416
- * @function
417
- * @return {Number} The length^2 of this vector.
418
- */
414
+ * return the square length of this vector
415
+ * @name length2
416
+ * @memberOf me.Vector2d
417
+ * @function
418
+ * @returns {number} The length^2 of this vector.
419
+ */
419
420
  length2() {
420
421
  return this.dotProduct(this);
421
422
  }
@@ -425,7 +426,7 @@ class Vector2d {
425
426
  * @name length
426
427
  * @memberOf me.Vector2d
427
428
  * @function
428
- * @return {Number} the length of this vector
429
+ * @returns {number} the length of this vector
429
430
  */
430
431
  length() {
431
432
  return Math.sqrt(this.length2());
@@ -437,8 +438,8 @@ class Vector2d {
437
438
  * @memberOf me.Vector2d
438
439
  * @function
439
440
  * @param {me.Vector2d} v
440
- * @param {Number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
441
- * @return {me.Vector2d} Reference to this object for method chaining
441
+ * @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
442
+ * @returns {me.Vector2d} Reference to this object for method chaining
442
443
  */
443
444
  lerp(v, alpha) {
444
445
  this.x += ( v.x - this.x ) * alpha;
@@ -452,7 +453,7 @@ class Vector2d {
452
453
  * @memberOf me.Vector2d
453
454
  * @function
454
455
  * @param {me.Vector2d} v
455
- * @return {Number}
456
+ * @returns {number}
456
457
  */
457
458
  distance(v) {
458
459
  var dx = this.x - v.x, dy = this.y - v.y;
@@ -465,7 +466,7 @@ class Vector2d {
465
466
  * @memberOf me.Vector2d
466
467
  * @function
467
468
  * @param {me.Vector2d} v
468
- * @return {Number} angle in radians
469
+ * @returns {number} angle in radians
469
470
  */
470
471
  angle(v) {
471
472
  return Math.acos(clamp(this.dotProduct(v) / (this.length() * v.length()), -1, 1));
@@ -477,7 +478,7 @@ class Vector2d {
477
478
  * @memberOf me.Vector2d
478
479
  * @function
479
480
  * @param {me.Vector2d} v The vector to project onto.
480
- * @return {me.Vector2d} Reference to this object for method chaining
481
+ * @returns {me.Vector2d} Reference to this object for method chaining
481
482
  */
482
483
  project(v) {
483
484
  return this.scale(this.dotProduct(v) / v.length2());
@@ -490,7 +491,7 @@ class Vector2d {
490
491
  * @memberOf me.Vector2d
491
492
  * @function
492
493
  * @param {me.Vector2d} v The unit vector to project onto.
493
- * @return {me.Vector2d} Reference to this object for method chaining
494
+ * @returns {me.Vector2d} Reference to this object for method chaining
494
495
  */
495
496
  projectN(v) {
496
497
  return this.scale(this.dotProduct(v));
@@ -501,7 +502,7 @@ class Vector2d {
501
502
  * @name clone
502
503
  * @memberOf me.Vector2d
503
504
  * @function
504
- * @return {me.Vector2d} new me.Vector2d
505
+ * @returns {me.Vector2d} new me.Vector2d
505
506
  */
506
507
  clone() {
507
508
  return pool.pull("Vector2d", this.x, this.y);
@@ -512,7 +513,7 @@ class Vector2d {
512
513
  * @name toString
513
514
  * @memberOf me.Vector2d
514
515
  * @function
515
- * @return {String}
516
+ * @returns {string}
516
517
  */
517
518
  toString() {
518
519
  return "x:" + this.x + ",y:" + this.y;