melonjs 10.2.3 → 10.5.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 (96) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +3620 -3582
  3. package/dist/melonjs.min.js +5 -5
  4. package/dist/melonjs.module.d.ts +3646 -4545
  5. package/dist/melonjs.module.js +3912 -3521
  6. package/package.json +21 -20
  7. package/src/audio/audio.js +30 -31
  8. package/src/camera/camera2d.js +47 -58
  9. package/src/entity/entity.js +32 -38
  10. package/src/game.js +21 -22
  11. package/src/{shapes → geometries}/ellipse.js +40 -47
  12. package/src/{shapes → geometries}/line.js +9 -12
  13. package/src/{shapes → geometries}/poly.js +100 -53
  14. package/src/{shapes → geometries}/rectangle.js +42 -45
  15. package/src/index.js +14 -32
  16. package/src/input/gamepad.js +11 -10
  17. package/src/input/input.js +2 -3
  18. package/src/input/keyboard.js +113 -113
  19. package/src/input/pointer.js +61 -29
  20. package/src/input/pointerevent.js +92 -29
  21. package/src/lang/deprecated.js +83 -13
  22. package/src/level/level.js +23 -24
  23. package/src/level/tiled/TMXGroup.js +7 -9
  24. package/src/level/tiled/TMXLayer.js +30 -33
  25. package/src/level/tiled/TMXObject.js +59 -53
  26. package/src/level/tiled/TMXTile.js +18 -19
  27. package/src/level/tiled/TMXTileMap.js +40 -46
  28. package/src/level/tiled/TMXTileset.js +12 -16
  29. package/src/level/tiled/TMXTilesetGroup.js +9 -10
  30. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
  31. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
  32. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
  33. package/src/level/tiled/renderer/TMXRenderer.js +24 -26
  34. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
  35. package/src/loader/loader.js +17 -16
  36. package/src/loader/loadingscreen.js +2 -5
  37. package/src/math/color.js +47 -67
  38. package/src/math/math.js +15 -16
  39. package/src/math/matrix2.js +53 -59
  40. package/src/math/matrix3.js +56 -63
  41. package/src/math/observable_vector2.js +87 -77
  42. package/src/math/observable_vector3.js +97 -80
  43. package/src/math/vector2.js +107 -97
  44. package/src/math/vector3.js +116 -100
  45. package/src/particles/emitter.js +66 -76
  46. package/src/particles/particle.js +4 -6
  47. package/src/particles/particlecontainer.js +2 -4
  48. package/src/physics/body.js +49 -147
  49. package/src/physics/bounds.js +48 -50
  50. package/src/physics/collision.js +13 -14
  51. package/src/physics/detector.js +18 -17
  52. package/src/physics/quadtree.js +17 -20
  53. package/src/physics/sat.js +30 -30
  54. package/src/physics/world.js +24 -29
  55. package/src/plugin/plugin.js +11 -15
  56. package/src/renderable/GUI.js +41 -47
  57. package/src/renderable/collectable.js +5 -10
  58. package/src/renderable/colorlayer.js +10 -15
  59. package/src/renderable/container.js +87 -73
  60. package/src/renderable/dragndrop.js +224 -0
  61. package/src/renderable/imagelayer.js +25 -32
  62. package/src/renderable/nineslicesprite.js +41 -42
  63. package/src/renderable/renderable.js +113 -124
  64. package/src/renderable/sprite.js +62 -69
  65. package/src/renderable/trigger.js +26 -32
  66. package/src/state/stage.js +13 -18
  67. package/src/state/state.js +26 -27
  68. package/src/system/device.js +76 -133
  69. package/src/system/event.js +81 -70
  70. package/src/system/pooling.js +11 -12
  71. package/src/system/save.js +3 -4
  72. package/src/system/timer.js +19 -20
  73. package/src/text/bitmaptext.js +57 -55
  74. package/src/text/bitmaptextdata.js +10 -11
  75. package/src/text/glyph.js +3 -0
  76. package/src/text/text.js +49 -55
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +1 -1
  79. package/src/tweens/tween.js +44 -46
  80. package/src/utils/agent.js +3 -4
  81. package/src/utils/array.js +4 -5
  82. package/src/utils/file.js +3 -4
  83. package/src/utils/function.js +4 -5
  84. package/src/utils/string.js +7 -9
  85. package/src/utils/utils.js +4 -5
  86. package/src/video/canvas/canvas_renderer.js +60 -62
  87. package/src/video/renderer.js +53 -58
  88. package/src/video/texture.js +98 -112
  89. package/src/video/texture_cache.js +26 -10
  90. package/src/video/video.js +15 -16
  91. package/src/video/webgl/buffer/vertex.js +2 -2
  92. package/src/video/webgl/glshader.js +37 -39
  93. package/src/video/webgl/webgl_compositor.js +128 -101
  94. package/src/video/webgl/webgl_renderer.js +126 -106
  95. package/src/entity/draggable.js +0 -139
  96. package/src/entity/droptarget.js +0 -109
@@ -22,24 +22,22 @@ import { Interpolation } from "./interpolation.js";
22
22
  * author Paul Lewis / http://www.aerotwist.com/<br>
23
23
  * author lechecacharro<br>
24
24
  * author Josh Faul / http://jocafa.com/
25
- * @class Tween
26
- * @memberOf me
27
- * @constructor
28
- * @param {object} object object on which to apply the tween
29
- * @example
30
- * // add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
31
- * tween = new me.Tween(myObject.pos).to({
32
- * x: 200,
33
- * y: 200,
34
- * }, {
35
- * duration: 3000,
36
- * easing: me.Tween.Easing.Bounce.Out,
37
- * autoStart : true
38
- * }).onComplete(myFunc);
39
25
  */
40
26
  class Tween {
41
27
 
42
- // constructor
28
+ /**
29
+ * @param {object} object object on which to apply the tween
30
+ * @example
31
+ * // add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
32
+ * tween = new me.Tween(myObject.pos).to({
33
+ * x: 200,
34
+ * y: 200,
35
+ * }, {
36
+ * duration: 3000,
37
+ * easing: me.Tween.Easing.Bounce.Out,
38
+ * autoStart : true
39
+ * }).onComplete(myFunc);
40
+ */
43
41
  constructor ( object ) {
44
42
  this.setProperties(object);
45
43
  }
@@ -121,19 +119,19 @@ class Tween {
121
119
  /**
122
120
  * object properties to be updated and duration
123
121
  * @name to
124
- * @memberOf me.Tween
122
+ * @memberof Tween
125
123
  * @public
126
124
  * @function
127
125
  * @param {object} properties hash of properties
128
126
  * @param {object|number} [options] object of tween properties, or a duration if a numeric value is passed
129
127
  * @param {number} [options.duration] tween duration
130
- * @param {me.Tween.Easing} [options.easing] easing function
128
+ * @param {Tween.Easing} [options.easing] easing function
131
129
  * @param {number} [options.delay] delay amount expressed in milliseconds
132
130
  * @param {boolean} [options.yoyo] allows the tween to bounce back to their original value when finished. To be used together with repeat to create endless loops.
133
131
  * @param {number} [options.repeat] amount of times the tween should be repeated
134
- * @param {me.Tween.Interpolation} [options.interpolation] interpolation function
132
+ * @param {Tween.Interpolation} [options.interpolation] interpolation function
135
133
  * @param {boolean} [options.autoStart] allow this tween to start automatically. Otherwise call me.Tween.start().
136
- * @returns {me.Tween} this instance for object chaining
134
+ * @returns {Tween} this instance for object chaining
137
135
  */
138
136
  to( properties, options ) {
139
137
 
@@ -163,11 +161,11 @@ class Tween {
163
161
  /**
164
162
  * start the tween
165
163
  * @name start
166
- * @memberOf me.Tween
164
+ * @memberof Tween
167
165
  * @public
168
166
  * @function
169
167
  * @param {number} [time] the current time when the tween was started
170
- * @returns {me.Tween} this instance for object chaining
168
+ * @returns {Tween} this instance for object chaining
171
169
  */
172
170
  start( time = timer.getTime() ) {
173
171
 
@@ -210,10 +208,10 @@ class Tween {
210
208
  /**
211
209
  * stop the tween
212
210
  * @name stop
213
- * @memberOf me.Tween
211
+ * @memberof Tween
214
212
  * @public
215
213
  * @function
216
- * @returns {me.Tween} this instance for object chaining
214
+ * @returns {Tween} this instance for object chaining
217
215
  */
218
216
  stop() {
219
217
  // remove the tween from the world container
@@ -224,11 +222,11 @@ class Tween {
224
222
  /**
225
223
  * delay the tween
226
224
  * @name delay
227
- * @memberOf me.Tween
225
+ * @memberof Tween
228
226
  * @public
229
227
  * @function
230
228
  * @param {number} amount delay amount expressed in milliseconds
231
- * @returns {me.Tween} this instance for object chaining
229
+ * @returns {Tween} this instance for object chaining
232
230
  */
233
231
  delay( amount ) {
234
232
 
@@ -240,11 +238,11 @@ class Tween {
240
238
  /**
241
239
  * Repeat the tween
242
240
  * @name repeat
243
- * @memberOf me.Tween
241
+ * @memberof Tween
244
242
  * @public
245
243
  * @function
246
244
  * @param {number} times amount of times the tween should be repeated
247
- * @returns {me.Tween} this instance for object chaining
245
+ * @returns {Tween} this instance for object chaining
248
246
  */
249
247
  repeat( times ) {
250
248
 
@@ -257,12 +255,12 @@ class Tween {
257
255
  * Allows the tween to bounce back to their original value when finished.
258
256
  * To be used together with repeat to create endless loops.
259
257
  * @name yoyo
260
- * @memberOf me.Tween
258
+ * @memberof Tween
261
259
  * @public
262
260
  * @function
263
- * @see me.Tween#repeat
261
+ * @see Tween#repeat
264
262
  * @param {boolean} yoyo
265
- * @returns {me.Tween} this instance for object chaining
263
+ * @returns {Tween} this instance for object chaining
266
264
  */
267
265
  yoyo( yoyo ) {
268
266
 
@@ -274,11 +272,11 @@ class Tween {
274
272
  /**
275
273
  * set the easing function
276
274
  * @name easing
277
- * @memberOf me.Tween
275
+ * @memberof Tween
278
276
  * @public
279
277
  * @function
280
- * @param {me.Tween.Easing} easing easing function
281
- * @returns {me.Tween} this instance for object chaining
278
+ * @param {Tween.Easing} easing easing function
279
+ * @returns {Tween} this instance for object chaining
282
280
  */
283
281
  easing( easing ) {
284
282
  if (typeof easing !== "function") {
@@ -291,11 +289,11 @@ class Tween {
291
289
  /**
292
290
  * set the interpolation function
293
291
  * @name interpolation
294
- * @memberOf me.Tween
292
+ * @memberof Tween
295
293
  * @public
296
294
  * @function
297
- * @param {me.Tween.Interpolation} interpolation interpolation function
298
- * @returns {me.Tween} this instance for object chaining
295
+ * @param {Tween.Interpolation} interpolation interpolation function
296
+ * @returns {Tween} this instance for object chaining
299
297
  */
300
298
  interpolation( interpolation ) {
301
299
  this._interpolationFunction = interpolation;
@@ -305,13 +303,13 @@ class Tween {
305
303
  /**
306
304
  * chain the tween
307
305
  * @name chain
308
- * @memberOf me.Tween
306
+ * @memberof Tween
309
307
  * @public
310
308
  * @function
311
- * @param {...me.Tween} chainedTween Tween(s) to be chained
312
- * @returns {me.Tween} this instance for object chaining
309
+ * @param {...Tween} chainedTween Tween(s) to be chained
310
+ * @returns {Tween} this instance for object chaining
313
311
  */
314
- chain( chainedTween ) {
312
+ chain() {
315
313
  this._chainedTweens = arguments;
316
314
  return this;
317
315
  }
@@ -319,11 +317,11 @@ class Tween {
319
317
  /**
320
318
  * onStart callback
321
319
  * @name onStart
322
- * @memberOf me.Tween
320
+ * @memberof Tween
323
321
  * @public
324
322
  * @function
325
323
  * @param {Function} onStartCallback callback
326
- * @returns {me.Tween} this instance for object chaining
324
+ * @returns {Tween} this instance for object chaining
327
325
  */
328
326
  onStart( onStartCallback ) {
329
327
  this._onStartCallback = onStartCallback;
@@ -333,11 +331,11 @@ class Tween {
333
331
  /**
334
332
  * onUpdate callback
335
333
  * @name onUpdate
336
- * @memberOf me.Tween
334
+ * @memberof Tween
337
335
  * @public
338
336
  * @function
339
337
  * @param {Function} onUpdateCallback callback
340
- * @returns {me.Tween} this instance for object chaining
338
+ * @returns {Tween} this instance for object chaining
341
339
  */
342
340
  onUpdate( onUpdateCallback ) {
343
341
  this._onUpdateCallback = onUpdateCallback;
@@ -347,11 +345,11 @@ class Tween {
347
345
  /**
348
346
  * onComplete callback
349
347
  * @name onComplete
350
- * @memberOf me.Tween
348
+ * @memberof Tween
351
349
  * @public
352
350
  * @function
353
351
  * @param {Function} onCompleteCallback callback
354
- * @returns {me.Tween} this instance for object chaining
352
+ * @returns {Tween} this instance for object chaining
355
353
  */
356
354
  onComplete( onCompleteCallback ) {
357
355
  this._onCompleteCallback = onCompleteCallback;
@@ -2,8 +2,7 @@ import { capitalize } from "./string.js";
2
2
 
3
3
  /**
4
4
  * a collection of utility functons to ease porting between different user agents.
5
- * @namespace me.utils.agent
6
- * @memberOf me
5
+ * @namespace utils.agent
7
6
  */
8
7
 
9
8
  /**
@@ -20,7 +19,7 @@ var vendors = [ "ms", "MS", "moz", "webkit", "o" ];
20
19
  * @param {string} name Property name
21
20
  * @param {object} [obj=window] Object or element reference to access
22
21
  * @returns {string} Value of property
23
- * @memberOf me.utils.agent
22
+ * @memberof utils.agent
24
23
  */
25
24
  export function prefixed(name, obj) {
26
25
  obj = obj || window;
@@ -47,7 +46,7 @@ export function prefixed(name, obj) {
47
46
  * @param {string} value Property value
48
47
  * @param {object} [obj=window] Object or element reference to access
49
48
  * @returns {boolean} true if one of the vendor-prefixed property was found
50
- * @memberOf me.utils.agent
49
+ * @memberof utils.agent
51
50
  */
52
51
  export function setPrefixed(name, value, obj) {
53
52
  obj = obj || window;
@@ -2,15 +2,14 @@ import {random as mathRandom, weightedRandom as mathWeightedRandom} from "./../m
2
2
 
3
3
  /**
4
4
  * a collection of array utility functions
5
- * @namespace me.utils.array
6
- * @memberOf me
5
+ * @namespace utils.array
7
6
  */
8
7
 
9
8
  /**
10
9
  * Remove the specified object from the given Array
11
10
  * @public
12
11
  * @function
13
- * @memberOf me.utils.array
12
+ * @memberof utils.array
14
13
  * @name remove
15
14
  * @param {Array} arr array from which to remove an object
16
15
  * @param {object} obj to be removed
@@ -31,7 +30,7 @@ export function remove(arr, obj) {
31
30
  * return a random array element
32
31
  * @public
33
32
  * @function
34
- * @memberOf me.utils.array
33
+ * @memberof utils.array
35
34
  * @name random
36
35
  * @param {Array} arr array to pick a element
37
36
  * @returns {any} random member of array
@@ -48,7 +47,7 @@ export function random(arr) {
48
47
  * return a weighted random array element, favoring the earlier entries
49
48
  * @public
50
49
  * @function
51
- * @memberOf me.utils.array
50
+ * @memberof utils.array
52
51
  * @name weightedRandom
53
52
  * @param {Array} arr array to pick a element
54
53
  * @returns {any} random member of array
package/src/utils/file.js CHANGED
@@ -1,8 +1,7 @@
1
1
 
2
2
  /**
3
3
  * a collection of file utility functions
4
- * @namespace me.utils.file
5
- * @memberOf me
4
+ * @namespace utils.file
6
5
  */
7
6
 
8
7
  // regexp to deal with file name & path
@@ -14,7 +13,7 @@ const REMOVE_EXT = /\.[^\.]*$/;
14
13
  * return the base name of the file without path info
15
14
  * @public
16
15
  * @function
17
- * @memberOf me.utils.file
16
+ * @memberof utils.file
18
17
  * @name getBasename
19
18
  * @param {string} path path containing the filename
20
19
  * @returns {string} the base name without path information.
@@ -27,7 +26,7 @@ export function getBasename(path) {
27
26
  * return the extension of the file in the given path
28
27
  * @public
29
28
  * @function
30
- * @memberOf me.utils.file
29
+ * @memberof utils.file
31
30
  * @name getExtension
32
31
  * @param {string} path path containing the filename
33
32
  * @returns {string} filename extension.
@@ -1,18 +1,17 @@
1
1
  /**
2
2
  * a collection of utility functions
3
- * @namespace me.utils.function
4
- * @memberOf me
3
+ * @namespace utils.function
5
4
  */
6
5
 
7
6
  /**
8
7
  * Executes a function as soon as the interpreter is idle (stack empty).
9
8
  * @public
10
9
  * @function
11
- * @memberOf me.utils.function
10
+ * @memberof utils.function
12
11
  * @name defer
13
12
  * @param {Function} func The function to be deferred.
14
13
  * @param {object} thisArg The value to be passed as the this parameter to the target function when the deferred function is called
15
- * @param {...*} [args] Optional additional arguments to carry for the function.
14
+ * @param {...*} args Optional additional arguments to carry for the function.
16
15
  * @returns {number} id that can be used to clear the deferred function using
17
16
  * clearTimeout
18
17
  * @example
@@ -29,7 +28,7 @@ export function defer(func, thisArg, ...args) {
29
28
  * once during a given window of time
30
29
  * @public
31
30
  * @function
32
- * @memberOf me.utils.function
31
+ * @memberof utils.function
33
32
  * @name throttle
34
33
  * @param {Function} fn the function to be throttled.
35
34
  * @param {number} delay The delay in ms
@@ -1,15 +1,13 @@
1
1
  /**
2
2
  * a collection of string utility functions
3
- * @namespace me.utils.string
4
- * @memberOf me
3
+ * @namespace utils.string
5
4
  */
6
5
 
7
-
8
6
  /**
9
7
  * converts the first character of the given string to uppercase
10
8
  * @public
11
9
  * @function
12
- * @memberOf me.utils.string
10
+ * @memberof utils.string
13
11
  * @name capitalize
14
12
  * @param {string} str the string to be capitalized
15
13
  * @returns {string} the capitalized string
@@ -22,7 +20,7 @@ export function capitalize(str) {
22
20
  * returns the string stripped of whitespace from the left.
23
21
  * @public
24
22
  * @function
25
- * @memberOf me.utils.string
23
+ * @memberof utils.string
26
24
  * @name trimLeft
27
25
  * @param {string} str the string to be trimmed
28
26
  * @returns {string} trimmed string
@@ -35,7 +33,7 @@ export function trimLeft(str) {
35
33
  * returns the string stripped of whitespace from the right.
36
34
  * @public
37
35
  * @function
38
- * @memberOf me.utils.string
36
+ * @memberof utils.string
39
37
  * @name trimRight
40
38
  * @param {string} str the string to be trimmed
41
39
  * @returns {string} trimmed string
@@ -48,7 +46,7 @@ export function trimRight(str) {
48
46
  * returns true if the given string contains a numeric integer or float value
49
47
  * @public
50
48
  * @function
51
- * @memberOf me.utils.string
49
+ * @memberof utils.string
52
50
  * @name isNumeric
53
51
  * @param {string} str the string to be tested
54
52
  * @returns {boolean} true if string contains only digits
@@ -64,7 +62,7 @@ export function isNumeric(str) {
64
62
  * returns true if the given string contains a true or false
65
63
  * @public
66
64
  * @function
67
- * @memberOf me.utils.string
65
+ * @memberof utils.string
68
66
  * @name isBoolean
69
67
  * @param {string} str the string to be tested
70
68
  * @returns {boolean} true if the string is either true or false
@@ -78,7 +76,7 @@ export function isBoolean(str) {
78
76
  * convert a string to the corresponding hexadecimal value
79
77
  * @public
80
78
  * @function
81
- * @memberOf me.utils.string
79
+ * @memberof utils.string
82
80
  * @name toHex
83
81
  * @param {string} str the string to be converted
84
82
  * @returns {string} the converted hexadecimal value
@@ -10,7 +10,6 @@ import { version } from "./../index.js";
10
10
  /**
11
11
  * a collection of utility functions
12
12
  * @namespace utils
13
- * @memberOf me
14
13
  */
15
14
 
16
15
  // guid default value
@@ -29,7 +28,7 @@ var utils = {
29
28
  * Get image pixels
30
29
  * @public
31
30
  * @function
32
- * @memberOf me.utils
31
+ * @memberof utils
33
32
  * @name getPixels
34
33
  * @param {HTMLImageElement|HTMLCanvasElement} image Image to read
35
34
  * @returns {ImageData} ImageData object
@@ -52,10 +51,10 @@ var utils = {
52
51
  * Compare two version strings
53
52
  * @public
54
53
  * @function
55
- * @memberOf me.utils
54
+ * @memberof utils
56
55
  * @name checkVersion
57
56
  * @param {string} first First version string to compare
58
- * @param {string} [second=me.version] Second version string to compare
57
+ * @param {string} [second=version] Second version string to compare
59
58
  * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
60
59
  * 0 : first == second<br>
61
60
  * &gt; 0 : first &gt; second
@@ -85,7 +84,7 @@ var utils = {
85
84
  * parse the fragment (hash) from a URL and returns them into
86
85
  * @public
87
86
  * @function
88
- * @memberOf me.utils
87
+ * @memberof utils
89
88
  * @name getUriFragment
90
89
  * @param {string} [url=document.location] an optional params string or URL containing fragment (hash) params to be parsed
91
90
  * @returns {object} an object representing the deserialized params string.