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
@@ -12,19 +12,19 @@ import { world, viewport } from "./../game.js";
12
12
  * @extends me.Renderable
13
13
  * @memberOf me
14
14
  * @constructor
15
- * @param {Number} x the x coordinates of the trigger area
16
- * @param {Number} y the y coordinates of the trigger area
17
- * @param {Number} [settings.width] width of the trigger area
18
- * @param {Number} [settings.height] height of the trigger area
15
+ * @param {number} x the x coordinates of the trigger area
16
+ * @param {number} y the y coordinates of the trigger area
17
+ * @param {number} [settings.width] width of the trigger area
18
+ * @param {number} [settings.height] height of the trigger area
19
19
  * @param {me.Rect[]|me.Polygon[]|me.Line[]|me.Ellipse[]} [settings.shapes] collision shape(s) that will trigger the event
20
- * @param {String} [settings.duration] Fade duration (in ms)
21
- * @param {String|me.Color} [settings.color] Fade color
22
- * @param {String} [settings.event="level"] the type of event to trigger (only "level" supported for now)
23
- * @param {String} [settings.to] level to load if level trigger
24
- * @param {String|me.Container} [settings.container] Target container. See {@link me.level.load}
20
+ * @param {string} [settings.duration] Fade duration (in ms)
21
+ * @param {string|me.Color} [settings.color] Fade color
22
+ * @param {string} [settings.event="level"] the type of event to trigger (only "level" supported for now)
23
+ * @param {string} [settings.to] level to load if level trigger
24
+ * @param {string|me.Container} [settings.container] Target container. See {@link me.level.load}
25
25
  * @param {Function} [settings.onLoaded] Level loaded callback. See {@link me.level.load}
26
- * @param {Boolean} [settings.flatten] Flatten all objects into the target container. See {@link me.level.load}
27
- * @param {Boolean} [settings.setViewportBounds] Resize the viewport to match the level. See {@link me.level.load}
26
+ * @param {boolean} [settings.flatten] Flatten all objects into the target container. See {@link me.level.load}
27
+ * @param {boolean} [settings.setViewportBounds] Resize the viewport to match the level. See {@link me.level.load}
28
28
  * @example
29
29
  * me.game.world.addChild(new me.Trigger(
30
30
  * x, y, {
@@ -102,11 +102,10 @@ class Trigger extends Renderable {
102
102
  }
103
103
 
104
104
  /**
105
- * go to the specified level
106
- * @name goTo
107
- * @memberOf me.LevelEntity
105
+ * trigger this event
106
+ * @name triggerEvent
107
+ * @memberOf me.Trigger
108
108
  * @function
109
- * @param {String} [level=this.nextlevel] name of the level to load
110
109
  * @protected
111
110
  */
112
111
  triggerEvent() {
@@ -8,10 +8,10 @@ import pool from "./../system/pooling.js";
8
8
  * @extends me.Object
9
9
  * @memberOf me
10
10
  * @constructor
11
- * @param {Number} x the center x coordinate of the ellipse
12
- * @param {Number} y the center y coordinate of the ellipse
13
- * @param {Number} w width (diameter) of the ellipse
14
- * @param {Number} h height (diameter) of the ellipse
11
+ * @param {number} x the center x coordinate of the ellipse
12
+ * @param {number} y the center y coordinate of the ellipse
13
+ * @param {number} w width (diameter) of the ellipse
14
+ * @param {number} h height (diameter) of the ellipse
15
15
  */
16
16
 
17
17
  class Ellipse {
@@ -38,7 +38,7 @@ class Ellipse {
38
38
  /**
39
39
  * Maximum radius of the ellipse
40
40
  * @public
41
- * @type {Number}
41
+ * @type {number}
42
42
  * @name radius
43
43
  * @memberOf me.Ellipse
44
44
  */
@@ -86,10 +86,11 @@ class Ellipse {
86
86
  * @name setShape
87
87
  * @memberOf me.Ellipse.prototype
88
88
  * @function
89
- * @param {Number} x the center x coordinate of the ellipse
90
- * @param {Number} y the center y coordinate of the ellipse
91
- * @param {Number} w width (diameter) of the ellipse
92
- * @param {Number} h height (diameter) of the ellipse
89
+ * @param {number} x the center x coordinate of the ellipse
90
+ * @param {number} y the center y coordinate of the ellipse
91
+ * @param {number} w width (diameter) of the ellipse
92
+ * @param {number} h height (diameter) of the ellipse
93
+ * @returns {me.Ellipse} this instance for objecf chaining
93
94
  */
94
95
  setShape(x, y, w, h) {
95
96
  var hW = w / 2;
@@ -115,9 +116,9 @@ class Ellipse {
115
116
  * @name rotate
116
117
  * @memberOf me.Ellipse.prototype
117
118
  * @function
118
- * @param {Number} angle The angle to rotate (in radians)
119
+ * @param {number} angle The angle to rotate (in radians)
119
120
  * @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
120
- * @return {me.Ellipse} Reference to this object for method chaining
121
+ * @returns {me.Ellipse} Reference to this object for method chaining
121
122
  */
122
123
  rotate(angle, v) {
123
124
  // TODO : only works for circle
@@ -132,9 +133,9 @@ class Ellipse {
132
133
  * @name scale
133
134
  * @memberOf me.Ellipse.prototype
134
135
  * @function
135
- * @param {Number} x
136
- * @param {Number} [y=x]
137
- * @return {me.Ellipse} Reference to this object for method chaining
136
+ * @param {number} x
137
+ * @param {number} [y=x]
138
+ * @returns {me.Ellipse} Reference to this object for method chaining
138
139
  */
139
140
  scale(x, y) {
140
141
  y = typeof (y) !== "undefined" ? y : x;
@@ -152,7 +153,7 @@ class Ellipse {
152
153
  * @memberOf me.Ellipse.prototype
153
154
  * @function
154
155
  * @param {me.Vector2d} v
155
- * @return {me.Ellipse} Reference to this object for method chaining
156
+ * @returns {me.Ellipse} Reference to this object for method chaining
156
157
  */
157
158
  scaleV(v) {
158
159
  return this.scale(v.x, v.y);
@@ -164,7 +165,7 @@ class Ellipse {
164
165
  * @memberOf me.Ellipse.prototype
165
166
  * @function
166
167
  * @param {me.Matrix2d} matrix the transformation matrix
167
- * @return {me.Polygon} Reference to this object for method chaining
168
+ * @returns {me.Polygon} Reference to this object for method chaining
168
169
  */
169
170
  transform(/* m */) {
170
171
  // TODO
@@ -176,9 +177,9 @@ class Ellipse {
176
177
  * @name translate
177
178
  * @memberOf me.Ellipse.prototype
178
179
  * @function
179
- * @param {Number} x x offset
180
- * @param {Number} y y offset
181
- * @return {me.Ellipse} this ellipse
180
+ * @param {number} x x offset
181
+ * @param {number} y y offset
182
+ * @returns {me.Ellipse} this ellipse
182
183
  */
183
184
  /**
184
185
  * translate the circle/ellipse by the specified vector
@@ -186,7 +187,7 @@ class Ellipse {
186
187
  * @memberOf me.Ellipse.prototype
187
188
  * @function
188
189
  * @param {me.Vector2d} v vector offset
189
- * @return {me.Ellipse} this ellipse
190
+ * @returns {me.Ellipse} this ellipse
190
191
  */
191
192
  translate() {
192
193
  var _x, _y;
@@ -214,7 +215,7 @@ class Ellipse {
214
215
  * @memberOf me.Ellipse.prototype
215
216
  * @function
216
217
  * @param {me.Vector2d} point
217
- * @return {boolean} true if contains
218
+ * @returns {boolean} true if contains
218
219
  */
219
220
 
220
221
  /**
@@ -222,9 +223,9 @@ class Ellipse {
222
223
  * @name contains
223
224
  * @memberOf me.Ellipse.prototype
224
225
  * @function
225
- * @param {Number} x x coordinate
226
- * @param {Number} y y coordinate
227
- * @return {boolean} true if contains
226
+ * @param {number} x x coordinate
227
+ * @param {number} y y coordinate
228
+ * @returns {boolean} true if contains
228
229
  */
229
230
  contains() {
230
231
  var _x, _y;
@@ -254,7 +255,7 @@ class Ellipse {
254
255
  * @name getBounds
255
256
  * @memberOf me.Ellipse.prototype
256
257
  * @function
257
- * @return {me.Bounds} this shape bounding box Rectangle object
258
+ * @returns {me.Bounds} this shape bounding box Rectangle object
258
259
  */
259
260
  getBounds() {
260
261
  if (typeof this._bounds === "undefined") {
@@ -268,7 +269,7 @@ class Ellipse {
268
269
  * @name clone
269
270
  * @memberOf me.Ellipse.prototype
270
271
  * @function
271
- * @return {me.Ellipse} new Ellipse
272
+ * @returns {me.Ellipse} new Ellipse
272
273
  */
273
274
  clone() {
274
275
  return new Ellipse(
@@ -8,8 +8,8 @@ import Polygon from "./poly.js";
8
8
  * @extends me.Polygon
9
9
  * @memberOf me
10
10
  * @constructor
11
- * @param {Number} x origin point of the Line
12
- * @param {Number} y origin point of the Line
11
+ * @param {number} x origin point of the Line
12
+ * @param {number} y origin point of the Line
13
13
  * @param {me.Vector2d[]} points array of vectors defining the Line
14
14
  */
15
15
 
@@ -21,7 +21,7 @@ class Line extends Polygon {
21
21
  * @memberOf me.Line.prototype
22
22
  * @function
23
23
  * @param {me.Vector2d} point
24
- * @return {boolean} true if contains
24
+ * @returns {boolean} true if contains
25
25
  */
26
26
 
27
27
  /**
@@ -29,9 +29,9 @@ class Line extends Polygon {
29
29
  * @name contains
30
30
  * @memberOf me.Line.prototype
31
31
  * @function
32
- * @param {Number} x x coordinate
33
- * @param {Number} y y coordinate
34
- * @return {boolean} true if contains
32
+ * @param {number} x x coordinate
33
+ * @param {number} y y coordinate
34
+ * @returns {boolean} true if contains
35
35
  */
36
36
  contains() {
37
37
  var _x, _y;
@@ -63,6 +63,7 @@ class Line extends Polygon {
63
63
  * @name recalc
64
64
  * @memberOf me.Line.prototype
65
65
  * @function
66
+ * @returns {me.Line} this instance for objecf chaining
66
67
  */
67
68
  recalc() {
68
69
  var edges = this.edges;
@@ -98,7 +99,7 @@ class Line extends Polygon {
98
99
  * @name clone
99
100
  * @memberOf me.Line.prototype
100
101
  * @function
101
- * @return {me.Line} new Line
102
+ * @returns {me.Line} new Line
102
103
  */
103
104
  clone() {
104
105
  var copy = [];
@@ -13,8 +13,8 @@ import pool from "./../system/pooling.js";
13
13
  * @class Polygon
14
14
  * @memberOf me
15
15
  * @constructor
16
- * @param {Number} x origin point of the Polygon
17
- * @param {Number} y origin point of the Polygon
16
+ * @param {number} x origin point of the Polygon
17
+ * @param {number} y origin point of the Polygon
18
18
  * @param {me.Vector2d[]} points array of vector defining the Polygon
19
19
  */
20
20
 
@@ -86,9 +86,10 @@ class Polygon {
86
86
  * @name setShape
87
87
  * @memberOf me.Polygon.prototype
88
88
  * @function
89
- * @param {Number} x position of the Polygon
90
- * @param {Number} y position of the Polygon
91
- * @param {me.Vector2d[]|Number[]} points array of vector or vertice defining the Polygon
89
+ * @param {number} x position of the Polygon
90
+ * @param {number} y position of the Polygon
91
+ * @param {me.Vector2d[]|number[]} points array of vector or vertice defining the Polygon
92
+ * @returns {me.Polygon} this instance for objecf chaining
92
93
  */
93
94
  setShape(x, y, points) {
94
95
  this.pos.set(x, y);
@@ -101,7 +102,8 @@ class Polygon {
101
102
  * @name setVertices
102
103
  * @memberOf me.Polygon.prototype
103
104
  * @function
104
- * @param {me.Vector2d[]} points array of vector or vertice defining the Polygon
105
+ * @param {me.Vector2d[]} vertices array of vector or vertice defining the Polygon
106
+ * @returns {me.Polygon} this instance for objecf chaining
105
107
  */
106
108
  setVertices(vertices) {
107
109
 
@@ -140,8 +142,8 @@ class Polygon {
140
142
  * @name transform
141
143
  * @memberOf me.Polygon.prototype
142
144
  * @function
143
- * @param {me.Matrix2d} matrix the transformation matrix
144
- * @return {me.Polygon} Reference to this object for method chaining
145
+ * @param {me.Matrix2d} m the transformation matrix
146
+ * @returns {me.Polygon} Reference to this object for method chaining
145
147
  */
146
148
  transform(m) {
147
149
  var points = this.points;
@@ -159,7 +161,7 @@ class Polygon {
159
161
  * @name toIso
160
162
  * @memberOf me.Polygon.prototype
161
163
  * @function
162
- * @return {me.Polygon} Reference to this object for method chaining
164
+ * @returns {me.Polygon} Reference to this object for method chaining
163
165
  */
164
166
  toIso() {
165
167
  return this.rotate(Math.PI / 4).scale(Math.SQRT2, Math.SQRT1_2);
@@ -170,7 +172,7 @@ class Polygon {
170
172
  * @name to2d
171
173
  * @memberOf me.Polygon.prototype
172
174
  * @function
173
- * @return {me.Polygon} Reference to this object for method chaining
175
+ * @returns {me.Polygon} Reference to this object for method chaining
174
176
  */
175
177
  to2d() {
176
178
  return this.scale(Math.SQRT1_2, Math.SQRT2).rotate(-Math.PI / 4);
@@ -181,9 +183,9 @@ class Polygon {
181
183
  * @name rotate
182
184
  * @memberOf me.Polygon.prototype
183
185
  * @function
184
- * @param {Number} angle The angle to rotate (in radians)
186
+ * @param {number} angle The angle to rotate (in radians)
185
187
  * @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
186
- * @return {me.Polygon} Reference to this object for method chaining
188
+ * @returns {me.Polygon} Reference to this object for method chaining
187
189
  */
188
190
  rotate(angle, v) {
189
191
  if (angle !== 0) {
@@ -203,9 +205,9 @@ class Polygon {
203
205
  * @name scale
204
206
  * @memberOf me.Polygon.prototype
205
207
  * @function
206
- * @param {Number} x
207
- * @param {Number} [y=x]
208
- * @return {me.Polygon} Reference to this object for method chaining
208
+ * @param {number} x
209
+ * @param {number} [y=x]
210
+ * @returns {me.Polygon} Reference to this object for method chaining
209
211
  */
210
212
  scale(x, y) {
211
213
  y = typeof (y) !== "undefined" ? y : x;
@@ -226,7 +228,7 @@ class Polygon {
226
228
  * @memberOf me.Polygon.prototype
227
229
  * @function
228
230
  * @param {me.Vector2d} v
229
- * @return {me.Polygon} Reference to this object for method chaining
231
+ * @returns {me.Polygon} Reference to this object for method chaining
230
232
  */
231
233
  scaleV(v) {
232
234
  return this.scale(v.x, v.y);
@@ -238,7 +240,7 @@ class Polygon {
238
240
  * @name recalc
239
241
  * @memberOf me.Polygon.prototype
240
242
  * @function
241
- * @return {me.Polygon} Reference to this object for method chaining
243
+ * @returns {me.Polygon} Reference to this object for method chaining
242
244
  */
243
245
  recalc() {
244
246
  var i;
@@ -281,7 +283,7 @@ class Polygon {
281
283
  * @name getIndices
282
284
  * @memberOf me.Polygon.prototype
283
285
  * @function
284
- * @return {Array} an array of vertex indices for all triangles forming this polygon.
286
+ * @returns {Array} an array of vertex indices for all triangles forming this polygon.
285
287
  */
286
288
  getIndices() {
287
289
  if (this.indices.length === 0) {
@@ -295,9 +297,9 @@ class Polygon {
295
297
  * @name translate
296
298
  * @memberOf me.Polygon.prototype
297
299
  * @function
298
- * @param {Number} x x offset
299
- * @param {Number} y y offset
300
- * @return {me.Polygon} this Polygon
300
+ * @param {number} x x offset
301
+ * @param {number} y y offset
302
+ * @returns {me.Polygon} this Polygon
301
303
  */
302
304
  /**
303
305
  * translate the Polygon by the specified vector
@@ -305,7 +307,7 @@ class Polygon {
305
307
  * @memberOf me.Polygon.prototype
306
308
  * @function
307
309
  * @param {me.Vector2d} v vector offset
308
- * @return {me.Polygon} Reference to this object for method chaining
310
+ * @returns {me.Polygon} Reference to this object for method chaining
309
311
  */
310
312
  translate() {
311
313
  var _x, _y;
@@ -339,8 +341,8 @@ class Polygon {
339
341
  * @name shift
340
342
  * @memberOf me.Polygon
341
343
  * @function
342
- * @param {Number} x
343
- * @param {Number} y
344
+ * @param {number} x
345
+ * @param {number} y
344
346
  */
345
347
  shift() {
346
348
  var _x, _y;
@@ -366,7 +368,7 @@ class Polygon {
366
368
  * @memberOf me.Polygon.prototype
367
369
  * @function
368
370
  * @param {me.Vector2d} point
369
- * @return {boolean} true if contains
371
+ * @returns {boolean} true if contains
370
372
  */
371
373
 
372
374
  /**
@@ -376,9 +378,9 @@ class Polygon {
376
378
  * @name contains
377
379
  * @memberOf me.Polygon.prototype
378
380
  * @function
379
- * @param {Number} x x coordinate
380
- * @param {Number} y y coordinate
381
- * @return {boolean} true if contains
381
+ * @param {number} x x coordinate
382
+ * @param {number} y y coordinate
383
+ * @returns {boolean} true if contains
382
384
  */
383
385
  contains() {
384
386
  var _x, _y;
@@ -414,7 +416,7 @@ class Polygon {
414
416
  * @name getBounds
415
417
  * @memberOf me.Polygon.prototype
416
418
  * @function
417
- * @return {me.Bounds} this shape bounding box Rectangle object
419
+ * @returns {me.Bounds} this shape bounding box Rectangle object
418
420
  */
419
421
  getBounds() {
420
422
  if (typeof this._bounds === "undefined") {
@@ -429,7 +431,7 @@ class Polygon {
429
431
  * @name updateBounds
430
432
  * @memberOf me.Polygon.prototype
431
433
  * @function
432
- * @return {me.Bounds} this shape bounding box Rectangle object
434
+ * @returns {me.Bounds} this shape bounding box Rectangle object
433
435
  */
434
436
  updateBounds() {
435
437
  var bounds = this.getBounds();
@@ -445,7 +447,7 @@ class Polygon {
445
447
  * @name clone
446
448
  * @memberOf me.Polygon.prototype
447
449
  * @function
448
- * @return {me.Polygon} new Polygon
450
+ * @returns {me.Polygon} new Polygon
449
451
  */
450
452
  clone() {
451
453
  var copy = [];