melonjs 10.3.0 → 10.4.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 (94) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +2419 -3072
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +3417 -3816
  5. package/dist/melonjs.module.js +2737 -3002
  6. package/package.json +16 -16
  7. package/src/audio/audio.js +29 -30
  8. package/src/camera/camera2d.js +46 -56
  9. package/src/entity/draggable.js +12 -13
  10. package/src/entity/droptarget.js +13 -15
  11. package/src/entity/entity.js +30 -36
  12. package/src/game.js +21 -22
  13. package/src/geometries/ellipse.js +40 -46
  14. package/src/geometries/line.js +9 -11
  15. package/src/geometries/poly.js +53 -53
  16. package/src/geometries/rectangle.js +42 -44
  17. package/src/index.js +4 -14
  18. package/src/input/gamepad.js +11 -10
  19. package/src/input/input.js +2 -3
  20. package/src/input/keyboard.js +113 -113
  21. package/src/input/pointer.js +30 -31
  22. package/src/input/pointerevent.js +26 -26
  23. package/src/lang/deprecated.js +25 -6
  24. package/src/level/level.js +23 -24
  25. package/src/level/tiled/TMXGroup.js +7 -8
  26. package/src/level/tiled/TMXLayer.js +30 -32
  27. package/src/level/tiled/TMXObject.js +21 -21
  28. package/src/level/tiled/TMXTile.js +18 -18
  29. package/src/level/tiled/TMXTileMap.js +37 -44
  30. package/src/level/tiled/TMXTileset.js +12 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +9 -9
  32. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  33. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
  34. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
  35. package/src/level/tiled/renderer/TMXRenderer.js +24 -25
  36. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
  37. package/src/loader/loader.js +14 -15
  38. package/src/loader/loadingscreen.js +2 -4
  39. package/src/math/color.js +47 -66
  40. package/src/math/math.js +15 -16
  41. package/src/math/matrix2.js +53 -58
  42. package/src/math/matrix3.js +56 -62
  43. package/src/math/observable_vector2.js +75 -76
  44. package/src/math/observable_vector3.js +79 -80
  45. package/src/math/vector2.js +91 -92
  46. package/src/math/vector3.js +94 -96
  47. package/src/particles/emitter.js +38 -40
  48. package/src/particles/particle.js +4 -5
  49. package/src/particles/particlecontainer.js +2 -3
  50. package/src/physics/body.js +44 -142
  51. package/src/physics/bounds.js +47 -47
  52. package/src/physics/collision.js +13 -14
  53. package/src/physics/detector.js +14 -14
  54. package/src/physics/quadtree.js +17 -19
  55. package/src/physics/sat.js +26 -26
  56. package/src/physics/world.js +24 -28
  57. package/src/plugin/plugin.js +11 -14
  58. package/src/renderable/GUI.js +41 -46
  59. package/src/renderable/collectable.js +4 -8
  60. package/src/renderable/colorlayer.js +6 -10
  61. package/src/renderable/container.js +87 -72
  62. package/src/renderable/imagelayer.js +25 -31
  63. package/src/renderable/nineslicesprite.js +41 -41
  64. package/src/renderable/renderable.js +112 -122
  65. package/src/renderable/sprite.js +62 -68
  66. package/src/renderable/trigger.js +25 -30
  67. package/src/state/stage.js +13 -17
  68. package/src/state/state.js +26 -27
  69. package/src/system/device.js +74 -75
  70. package/src/system/event.js +71 -72
  71. package/src/system/pooling.js +11 -12
  72. package/src/system/save.js +3 -4
  73. package/src/system/timer.js +19 -20
  74. package/src/text/bitmaptext.js +57 -54
  75. package/src/text/bitmaptextdata.js +10 -10
  76. package/src/text/glyph.js +3 -0
  77. package/src/text/text.js +44 -49
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +1 -1
  80. package/src/tweens/tween.js +43 -44
  81. package/src/utils/agent.js +3 -4
  82. package/src/utils/array.js +4 -5
  83. package/src/utils/file.js +3 -4
  84. package/src/utils/function.js +4 -5
  85. package/src/utils/string.js +7 -9
  86. package/src/utils/utils.js +4 -5
  87. package/src/video/canvas/canvas_renderer.js +58 -59
  88. package/src/video/renderer.js +49 -53
  89. package/src/video/texture.js +98 -111
  90. package/src/video/texture_cache.js +2 -2
  91. package/src/video/video.js +15 -16
  92. package/src/video/webgl/glshader.js +37 -38
  93. package/src/video/webgl/webgl_compositor.js +31 -32
  94. package/src/video/webgl/webgl_renderer.js +79 -80
package/src/math/math.js CHANGED
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * a collection of math utility functions
3
3
  * @namespace Math
4
- * @memberof me
5
4
  */
6
5
 
7
6
  /**
@@ -9,7 +8,7 @@
9
8
  * @public
10
9
  * @type {number}
11
10
  * @name DEG_TO_RAD
12
- * @memberof me.Math
11
+ * @memberof Math
13
12
  */
14
13
  export const DEG_TO_RAD = Math.PI / 180.0;
15
14
 
@@ -18,7 +17,7 @@ export const DEG_TO_RAD = Math.PI / 180.0;
18
17
  * @public
19
18
  * @type {number}
20
19
  * @name RAD_TO_DEG
21
- * @memberof me.Math
20
+ * @memberof Math
22
21
  */
23
22
  export const RAD_TO_DEG = 180.0 / Math.PI;
24
23
 
@@ -27,7 +26,7 @@ export const RAD_TO_DEG = 180.0 / Math.PI;
27
26
  * @public
28
27
  * @type {number}
29
28
  * @name TAU
30
- * @memberof me.Math
29
+ * @memberof Math
31
30
  */
32
31
  export const TAU = Math.PI * 2;
33
32
 
@@ -36,7 +35,7 @@ export const TAU = Math.PI * 2;
36
35
  * @public
37
36
  * @type {number}
38
37
  * @name ETA
39
- * @memberof me.Math
38
+ * @memberof Math
40
39
  */
41
40
  export const ETA = Math.PI * 0.5;
42
41
 
@@ -45,7 +44,7 @@ export const ETA = Math.PI * 0.5;
45
44
  * @public
46
45
  * @type {number}
47
46
  * @name EPSILON
48
- * @memberof me.Math
47
+ * @memberof Math
49
48
  */
50
49
  export const EPSILON = 0.000001;
51
50
 
@@ -53,7 +52,7 @@ export const EPSILON = 0.000001;
53
52
  * returns true if the given value is a power of two
54
53
  * @public
55
54
  * @function
56
- * @memberof me.Math
55
+ * @memberof Math
57
56
  * @name isPowerOfTwo
58
57
  * @param {number} val
59
58
  * @returns {boolean}
@@ -66,7 +65,7 @@ export function isPowerOfTwo(val) {
66
65
  * returns the next power of two for the given value
67
66
  * @public
68
67
  * @function
69
- * @memberof me.Math
68
+ * @memberof Math
70
69
  * @name nextPowerOfTwo
71
70
  * @param {number} val
72
71
  * @returns {boolean}
@@ -86,7 +85,7 @@ export function nextPowerOfTwo(val) {
86
85
  * Converts an angle in degrees to an angle in radians
87
86
  * @public
88
87
  * @function
89
- * @memberof me.Math
88
+ * @memberof Math
90
89
  * @name degToRad
91
90
  * @param {number} angle angle in degrees
92
91
  * @returns {number} corresponding angle in radians
@@ -102,7 +101,7 @@ export function degToRad(angle) {
102
101
  * Converts an angle in radians to an angle in degrees.
103
102
  * @public
104
103
  * @function
105
- * @memberof me.Math
104
+ * @memberof Math
106
105
  * @name radToDeg
107
106
  * @param {number} radians angle in radians
108
107
  * @returns {number} corresponding angle in degrees
@@ -118,7 +117,7 @@ export function radToDeg(radians) {
118
117
  * clamp the given value
119
118
  * @public
120
119
  * @function
121
- * @memberof me.Math
120
+ * @memberof Math
122
121
  * @name clamp
123
122
  * @param {number} val the value to clamp
124
123
  * @param {number} low lower limit
@@ -133,7 +132,7 @@ export function clamp(val, low, high) {
133
132
  * return a random integer between min (included) and max (excluded)
134
133
  * @public
135
134
  * @function
136
- * @memberof me.Math
135
+ * @memberof Math
137
136
  * @name random
138
137
  * @param {number} min minimum value.
139
138
  * @param {number} max maximum value.
@@ -150,7 +149,7 @@ export function random(min, max) {
150
149
  * return a random float between min, max (exclusive)
151
150
  * @public
152
151
  * @function
153
- * @memberof me.Math
152
+ * @memberof Math
154
153
  * @name randomFloat
155
154
  * @param {number} min minimum value.
156
155
  * @param {number} max maximum value.
@@ -167,7 +166,7 @@ export function randomFloat(min, max) {
167
166
  * return a weighted random between min, max (exclusive)
168
167
  * @public
169
168
  * @function
170
- * @memberof me.Math
169
+ * @memberof Math
171
170
  * @name weightedRandom
172
171
  * @param {number} min minimum value.
173
172
  * @param {number} max maximum value.
@@ -184,7 +183,7 @@ export function weightedRandom(min, max) {
184
183
  * round a value to the specified number of digit
185
184
  * @public
186
185
  * @function
187
- * @memberof me.Math
186
+ * @memberof Math
188
187
  * @name round
189
188
  * @param {number} num value to be rounded.
190
189
  * @param {number} [dec=0] number of decimal digit to be rounded to.
@@ -203,7 +202,7 @@ export function round(num, dec = 0) {
203
202
  * check if the given value is close to the expected one
204
203
  * @public
205
204
  * @function
206
- * @memberof me.Math
205
+ * @memberof Math
207
206
  * @name toBeCloseTo
208
207
  * @param {number} expected value to be compared with.
209
208
  * @param {number} actual actual value to compare
@@ -6,14 +6,11 @@ import Matrix3d from "./matrix3.js";
6
6
  * a Matrix2d Object.<br>
7
7
  * the identity matrix and parameters position : <br>
8
8
  * <img src="images/identity-matrix_2x.png"/>
9
- * @class Matrix2d
10
- * @memberof me
11
- * @param {me.Matrix2d} [mat2d] An instance of me.Matrix2d to copy from
12
- * @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix2d.setTransform}
13
9
  */
14
-
15
10
  class Matrix2d {
16
-
11
+ /**
12
+ * @param {(Matrix2d|Matrix3d|...number)} args an instance of me.Matrix2d or me.Matrix3d to copy from, or individual matrix components (See {@link Matrix2d.setTransform}). If not arguments are given, the matrix will be set to Identity.
13
+ */
17
14
  constructor(...args) {
18
15
  this.onResetEvent(...args);
19
16
  }
@@ -45,10 +42,9 @@ class Matrix2d {
45
42
  * tx component of the matrix
46
43
  * @public
47
44
  * @type {number}
48
- * @readonly
49
- * @see me.Matrix2d.translate
45
+ * @see Matrix2d.translate
50
46
  * @name tx
51
- * @memberof me.Matrix2d
47
+ * @memberof Matrix2d
52
48
  */
53
49
  get tx() {
54
50
  return this.val[6];
@@ -58,10 +54,9 @@ class Matrix2d {
58
54
  * ty component of the matrix
59
55
  * @public
60
56
  * @type {number}
61
- * @readonly
62
- * @see me.Matrix2d.translate
57
+ * @see Matrix2d.translate
63
58
  * @name ty
64
- * @memberof me.Matrix2d
59
+ * @memberof Matrix2d
65
60
  */
66
61
  get ty() {
67
62
  return this.val[7];
@@ -72,9 +67,9 @@ class Matrix2d {
72
67
  * the identity matrix and parameters position : <br>
73
68
  * <img src="images/identity-matrix_2x.png"/>
74
69
  * @name identity
75
- * @memberof me.Matrix2d
70
+ * @memberof Matrix2d
76
71
  * @function
77
- * @returns {me.Matrix2d} Reference to this object for method chaining
72
+ * @returns {Matrix2d} Reference to this object for method chaining
78
73
  */
79
74
  identity() {
80
75
  this.setTransform(
@@ -88,7 +83,7 @@ class Matrix2d {
88
83
  /**
89
84
  * set the matrix to the specified value
90
85
  * @name setTransform
91
- * @memberof me.Matrix2d
86
+ * @memberof Matrix2d
92
87
  * @function
93
88
  * @param {number} a
94
89
  * @param {number} b
@@ -99,7 +94,7 @@ class Matrix2d {
99
94
  * @param {number} [g=0]
100
95
  * @param {number} [h=0]
101
96
  * @param {number} [i=1]
102
- * @returns {me.Matrix2d} Reference to this object for method chaining
97
+ * @returns {Matrix2d} Reference to this object for method chaining
103
98
  */
104
99
  setTransform() {
105
100
  var a = this.val;
@@ -132,10 +127,10 @@ class Matrix2d {
132
127
  /**
133
128
  * Copies over the values from another me.Matrix2d.
134
129
  * @name copy
135
- * @memberof me.Matrix2d
130
+ * @memberof Matrix2d
136
131
  * @function
137
- * @param {me.Matrix2d} m the matrix object to copy from
138
- * @returns {me.Matrix2d} Reference to this object for method chaining
132
+ * @param {Matrix2d} m the matrix object to copy from
133
+ * @returns {Matrix2d} Reference to this object for method chaining
139
134
  */
140
135
  copy(m) {
141
136
  this.val.set(m.val);
@@ -145,10 +140,10 @@ class Matrix2d {
145
140
  /**
146
141
  * Copies over the upper-left 3x3 values from the given me.Matrix3d
147
142
  * @name fromMat3d
148
- * @memberof me.Matrix2d
143
+ * @memberof Matrix2d
149
144
  * @function
150
- * @param {me.Matrix3d} m the matrix object to copy from
151
- * @returns {me.Matrix2d} Reference to this object for method chaining
145
+ * @param {Matrix3d} m the matrix object to copy from
146
+ * @returns {Matrix2d} Reference to this object for method chaining
152
147
  */
153
148
  fromMat3d(m) {
154
149
  var b = m.val;
@@ -170,10 +165,10 @@ class Matrix2d {
170
165
  /**
171
166
  * multiply both matrix
172
167
  * @name multiply
173
- * @memberof me.Matrix2d
168
+ * @memberof Matrix2d
174
169
  * @function
175
- * @param {me.Matrix2d} m the other matrix
176
- * @returns {me.Matrix2d} Reference to this object for method chaining
170
+ * @param {Matrix2d} m the other matrix
171
+ * @returns {Matrix2d} Reference to this object for method chaining
177
172
  */
178
173
  multiply(m) {
179
174
  var b = m.val;
@@ -202,9 +197,9 @@ class Matrix2d {
202
197
  /**
203
198
  * Transpose the value of this matrix.
204
199
  * @name transpose
205
- * @memberof me.Matrix2d
200
+ * @memberof Matrix2d
206
201
  * @function
207
- * @returns {me.Matrix2d} Reference to this object for method chaining
202
+ * @returns {Matrix2d} Reference to this object for method chaining
208
203
  */
209
204
  transpose() {
210
205
  var a = this.val,
@@ -225,9 +220,9 @@ class Matrix2d {
225
220
  /**
226
221
  * invert this matrix, causing it to apply the opposite transformation.
227
222
  * @name invert
228
- * @memberof me.Matrix2d
223
+ * @memberof Matrix2d
229
224
  * @function
230
- * @returns {me.Matrix2d} Reference to this object for method chaining
225
+ * @returns {Matrix2d} Reference to this object for method chaining
231
226
  */
232
227
  invert() {
233
228
  var val = this.val;
@@ -260,10 +255,10 @@ class Matrix2d {
260
255
  /**
261
256
  * apply the current transform to the given 2d vector
262
257
  * @name apply
263
- * @memberof me.Matrix2d
258
+ * @memberof Matrix2d
264
259
  * @function
265
- * @param {me.Vector2d} v the vector object to be transformed
266
- * @returns {me.Vector2d} result vector object.
260
+ * @param {Vector2d} v the vector object to be transformed
261
+ * @returns {Vector2d} result vector object.
267
262
  */
268
263
  apply(v) {
269
264
  var a = this.val,
@@ -279,10 +274,10 @@ class Matrix2d {
279
274
  /**
280
275
  * apply the inverted current transform to the given 2d vector
281
276
  * @name applyInverse
282
- * @memberof me.Matrix2d
277
+ * @memberof Matrix2d
283
278
  * @function
284
- * @param {me.Vector2d} v the vector object to be transformed
285
- * @returns {me.Vector2d} result vector object.
279
+ * @param {Vector2d} v the vector object to be transformed
280
+ * @returns {Vector2d} result vector object.
286
281
  */
287
282
  applyInverse(v) {
288
283
  var a = this.val,
@@ -300,11 +295,11 @@ class Matrix2d {
300
295
  /**
301
296
  * scale the matrix
302
297
  * @name scale
303
- * @memberof me.Matrix2d
298
+ * @memberof Matrix2d
304
299
  * @function
305
300
  * @param {number} x a number representing the abscissa of the scaling vector.
306
301
  * @param {number} [y=x] a number representing the ordinate of the scaling vector.
307
- * @returns {me.Matrix2d} Reference to this object for method chaining
302
+ * @returns {Matrix2d} Reference to this object for method chaining
308
303
  */
309
304
  scale(x, y) {
310
305
  var a = this.val,
@@ -322,10 +317,10 @@ class Matrix2d {
322
317
  /**
323
318
  * adds a 2D scaling transformation.
324
319
  * @name scaleV
325
- * @memberof me.Matrix2d
320
+ * @memberof Matrix2d
326
321
  * @function
327
- * @param {me.Vector2d} v scaling vector
328
- * @returns {me.Matrix2d} Reference to this object for method chaining
322
+ * @param {Vector2d} v scaling vector
323
+ * @returns {Matrix2d} Reference to this object for method chaining
329
324
  */
330
325
  scaleV(v) {
331
326
  return this.scale(v.x, v.y);
@@ -334,10 +329,10 @@ class Matrix2d {
334
329
  /**
335
330
  * specifies a 2D scale operation using the [sx, 1] scaling vector
336
331
  * @name scaleX
337
- * @memberof me.Matrix2d
332
+ * @memberof Matrix2d
338
333
  * @function
339
334
  * @param {number} x x scaling vector
340
- * @returns {me.Matrix2d} Reference to this object for method chaining
335
+ * @returns {Matrix2d} Reference to this object for method chaining
341
336
  */
342
337
  scaleX(x) {
343
338
  return this.scale(x, 1);
@@ -346,10 +341,10 @@ class Matrix2d {
346
341
  /**
347
342
  * specifies a 2D scale operation using the [1,sy] scaling vector
348
343
  * @name scaleY
349
- * @memberof me.Matrix2d
344
+ * @memberof Matrix2d
350
345
  * @function
351
346
  * @param {number} y y scaling vector
352
- * @returns {me.Matrix2d} Reference to this object for method chaining
347
+ * @returns {Matrix2d} Reference to this object for method chaining
353
348
  */
354
349
  scaleY(y) {
355
350
  return this.scale(1, y);
@@ -358,10 +353,10 @@ class Matrix2d {
358
353
  /**
359
354
  * rotate the matrix (counter-clockwise) by the specified angle (in radians).
360
355
  * @name rotate
361
- * @memberof me.Matrix2d
356
+ * @memberof Matrix2d
362
357
  * @function
363
358
  * @param {number} angle Rotation angle in radians.
364
- * @returns {me.Matrix2d} Reference to this object for method chaining
359
+ * @returns {Matrix2d} Reference to this object for method chaining
365
360
  */
366
361
  rotate(angle) {
367
362
  if (angle !== 0) {
@@ -389,19 +384,19 @@ class Matrix2d {
389
384
  /**
390
385
  * translate the matrix position on the horizontal and vertical axis
391
386
  * @name translate
392
- * @memberof me.Matrix2d
387
+ * @memberof Matrix2d
393
388
  * @function
394
389
  * @param {number} x the x coordindates to translate the matrix by
395
390
  * @param {number} y the y coordindates to translate the matrix by
396
- * @returns {me.Matrix2d} Reference to this object for method chaining
391
+ * @returns {Matrix2d} Reference to this object for method chaining
397
392
  */
398
393
  /**
399
394
  * translate the matrix by a vector on the horizontal and vertical axis
400
395
  * @name translateV
401
- * @memberof me.Matrix2d
396
+ * @memberof Matrix2d
402
397
  * @function
403
- * @param {me.Vector2d} v the vector to translate the matrix by
404
- * @returns {me.Matrix2d} Reference to this object for method chaining
398
+ * @param {Vector2d} v the vector to translate the matrix by
399
+ * @returns {Matrix2d} Reference to this object for method chaining
405
400
  */
406
401
  translate() {
407
402
  var a = this.val;
@@ -426,7 +421,7 @@ class Matrix2d {
426
421
  /**
427
422
  * returns true if the matrix is an identity matrix.
428
423
  * @name isIdentity
429
- * @memberof me.Matrix2d
424
+ * @memberof Matrix2d
430
425
  * @function
431
426
  * @returns {boolean}
432
427
  */
@@ -449,9 +444,9 @@ class Matrix2d {
449
444
  /**
450
445
  * return true if the two matrices are identical
451
446
  * @name equals
452
- * @memberof me.Matrix2d
447
+ * @memberof Matrix2d
453
448
  * @function
454
- * @param {me.Matrix2d} m the other matrix
449
+ * @param {Matrix2d} m the other matrix
455
450
  * @returns {boolean} true if both are equals
456
451
  */
457
452
  equals(m) {
@@ -474,9 +469,9 @@ class Matrix2d {
474
469
  /**
475
470
  * Clone the Matrix
476
471
  * @name clone
477
- * @memberof me.Matrix2d
472
+ * @memberof Matrix2d
478
473
  * @function
479
- * @returns {me.Matrix2d}
474
+ * @returns {Matrix2d}
480
475
  */
481
476
  clone() {
482
477
  return pool.pull("Matrix2d", this);
@@ -485,7 +480,7 @@ class Matrix2d {
485
480
  /**
486
481
  * return an array representation of this Matrix
487
482
  * @name toArray
488
- * @memberof me.Matrix2d
483
+ * @memberof Matrix2d
489
484
  * @function
490
485
  * @returns {Float32Array}
491
486
  */
@@ -496,7 +491,7 @@ class Matrix2d {
496
491
  /**
497
492
  * convert the object to a string representation
498
493
  * @name toString
499
- * @memberof me.Matrix2d
494
+ * @memberof Matrix2d
500
495
  * @function
501
496
  * @returns {string}
502
497
  */