melonjs 10.2.0 → 10.3.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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.js +4435 -4283
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3348 -3833
  5. package/dist/melonjs.module.js +4025 -3920
  6. package/package.json +13 -14
  7. package/src/audio/audio.js +45 -45
  8. package/src/camera/camera2d.js +78 -101
  9. package/src/entity/draggable.js +21 -29
  10. package/src/entity/droptarget.js +24 -31
  11. package/src/entity/entity.js +34 -38
  12. package/src/game.js +8 -8
  13. package/src/{shapes → geometries}/ellipse.js +46 -46
  14. package/src/{shapes → geometries}/line.js +14 -14
  15. package/src/{shapes → geometries}/poly.js +103 -54
  16. package/src/{shapes → geometries}/rectangle.js +73 -120
  17. package/src/index.js +18 -19
  18. package/src/input/gamepad.js +20 -20
  19. package/src/input/input.js +3 -3
  20. package/src/input/keyboard.js +122 -124
  21. package/src/input/pointer.js +102 -62
  22. package/src/input/pointerevent.js +97 -42
  23. package/src/lang/deprecated.js +29 -18
  24. package/src/level/level.js +34 -26
  25. package/src/level/tiled/TMXGroup.js +12 -13
  26. package/src/level/tiled/TMXLayer.js +41 -42
  27. package/src/level/tiled/TMXObject.js +76 -70
  28. package/src/level/tiled/TMXTile.js +13 -15
  29. package/src/level/tiled/TMXTileMap.js +26 -25
  30. package/src/level/tiled/TMXTileset.js +14 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +5 -6
  32. package/src/level/tiled/TMXUtils.js +13 -11
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
  35. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
  36. package/src/level/tiled/renderer/TMXRenderer.js +18 -19
  37. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
  38. package/src/loader/loader.js +46 -40
  39. package/src/loader/loadingscreen.js +7 -7
  40. package/src/math/color.js +68 -88
  41. package/src/math/math.js +33 -33
  42. package/src/math/matrix2.js +70 -71
  43. package/src/math/matrix3.js +90 -91
  44. package/src/math/observable_vector2.js +91 -92
  45. package/src/math/observable_vector3.js +110 -106
  46. package/src/math/vector2.js +116 -104
  47. package/src/math/vector3.js +129 -110
  48. package/src/particles/emitter.js +116 -126
  49. package/src/particles/particle.js +4 -5
  50. package/src/particles/particlecontainer.js +2 -3
  51. package/src/physics/body.js +82 -83
  52. package/src/physics/bounds.js +64 -66
  53. package/src/physics/collision.js +21 -22
  54. package/src/physics/detector.js +13 -13
  55. package/src/physics/quadtree.js +26 -25
  56. package/src/physics/sat.js +21 -21
  57. package/src/physics/world.js +23 -22
  58. package/src/plugin/plugin.js +12 -13
  59. package/src/renderable/GUI.js +20 -26
  60. package/src/renderable/collectable.js +6 -7
  61. package/src/renderable/colorlayer.js +11 -12
  62. package/src/renderable/container.js +98 -81
  63. package/src/renderable/imagelayer.js +33 -35
  64. package/src/renderable/nineslicesprite.js +15 -16
  65. package/src/renderable/renderable.js +112 -111
  66. package/src/renderable/sprite.js +71 -58
  67. package/src/renderable/trigger.js +17 -19
  68. package/src/state/stage.js +14 -15
  69. package/src/state/state.js +78 -78
  70. package/src/system/device.js +137 -180
  71. package/src/system/event.js +116 -104
  72. package/src/system/pooling.js +15 -15
  73. package/src/system/save.js +9 -6
  74. package/src/system/timer.js +33 -33
  75. package/src/text/bitmaptext.js +39 -46
  76. package/src/text/bitmaptextdata.js +14 -15
  77. package/src/text/text.js +55 -58
  78. package/src/tweens/easing.js +5 -5
  79. package/src/tweens/interpolation.js +5 -5
  80. package/src/tweens/tween.js +49 -40
  81. package/src/utils/agent.js +12 -11
  82. package/src/utils/array.js +8 -8
  83. package/src/utils/file.js +7 -7
  84. package/src/utils/function.js +8 -8
  85. package/src/utils/string.js +19 -19
  86. package/src/utils/utils.js +23 -23
  87. package/src/video/canvas/canvas_renderer.js +127 -128
  88. package/src/video/renderer.js +69 -69
  89. package/src/video/texture.js +80 -82
  90. package/src/video/texture_cache.js +2 -4
  91. package/src/video/video.js +38 -38
  92. package/src/video/webgl/buffer/vertex.js +11 -3
  93. package/src/video/webgl/glshader.js +31 -32
  94. package/src/video/webgl/webgl_compositor.js +145 -127
  95. package/src/video/webgl/webgl_renderer.js +196 -175
package/src/utils/file.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * a collection of file utility functions
4
4
  * @namespace me.utils.file
5
- * @memberOf me
5
+ * @memberof me
6
6
  */
7
7
 
8
8
  // regexp to deal with file name & path
@@ -14,10 +14,10 @@ const REMOVE_EXT = /\.[^\.]*$/;
14
14
  * return the base name of the file without path info
15
15
  * @public
16
16
  * @function
17
- * @memberOf me.utils.file
17
+ * @memberof me.utils.file
18
18
  * @name getBasename
19
- * @param {String} path path containing the filename
20
- * @return {String} the base name without path information.
19
+ * @param {string} path path containing the filename
20
+ * @returns {string} the base name without path information.
21
21
  */
22
22
  export function getBasename(path) {
23
23
  return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
@@ -27,10 +27,10 @@ export function getBasename(path) {
27
27
  * return the extension of the file in the given path
28
28
  * @public
29
29
  * @function
30
- * @memberOf me.utils.file
30
+ * @memberof me.utils.file
31
31
  * @name getExtension
32
- * @param {String} path path containing the filename
33
- * @return {String} filename extension.
32
+ * @param {string} path path containing the filename
33
+ * @returns {string} filename extension.
34
34
  */
35
35
  export function getExtension(path) {
36
36
  return path.substring(path.lastIndexOf(".") + 1, path.length);
@@ -1,20 +1,19 @@
1
1
  /**
2
2
  * a collection of utility functions
3
3
  * @namespace me.utils.function
4
- * @memberOf me
4
+ * @memberof me
5
5
  */
6
6
 
7
-
8
7
  /**
9
8
  * Executes a function as soon as the interpreter is idle (stack empty).
10
9
  * @public
11
10
  * @function
12
- * @memberOf me.utils.function
11
+ * @memberof me.utils.function
13
12
  * @name defer
14
- * @param {Function} fn The function to be deferred.
15
- * @param {Object} thisArg The value to be passed as the this parameter to the target function when the deferred function is called
13
+ * @param {Function} func The function to be deferred.
14
+ * @param {object} thisArg The value to be passed as the this parameter to the target function when the deferred function is called
16
15
  * @param {...*} [args] Optional additional arguments to carry for the function.
17
- * @return {Number} id that can be used to clear the deferred function using
16
+ * @returns {number} id that can be used to clear the deferred function using
18
17
  * clearTimeout
19
18
  * @example
20
19
  * // execute myFunc() when the stack is empty,
@@ -30,11 +29,12 @@ export function defer(func, thisArg, ...args) {
30
29
  * once during a given window of time
31
30
  * @public
32
31
  * @function
33
- * @memberOf me.utils.function
32
+ * @memberof me.utils.function
34
33
  * @name throttle
35
34
  * @param {Function} fn the function to be throttled.
36
- * @param {Number} delay The delay in ms
35
+ * @param {number} delay The delay in ms
37
36
  * @param {no_trailing} no_trailing disable the execution on the trailing edge
37
+ * @returns {Function} the function that will be throttled
38
38
  */
39
39
  export function throttle(fn, delay, no_trailing) {
40
40
  var last = window.performance.now(), deferTimer;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * a collection of string utility functions
3
3
  * @namespace me.utils.string
4
- * @memberOf me
4
+ * @memberof me
5
5
  */
6
6
 
7
7
 
@@ -9,10 +9,10 @@
9
9
  * converts the first character of the given string to uppercase
10
10
  * @public
11
11
  * @function
12
- * @memberOf me.utils.string
12
+ * @memberof me.utils.string
13
13
  * @name capitalize
14
- * @param {String} string the string to be capitalized
15
- * @return {string} the capitalized string
14
+ * @param {string} str the string to be capitalized
15
+ * @returns {string} the capitalized string
16
16
  */
17
17
  export function capitalize(str) {
18
18
  return str.charAt(0).toUpperCase() + str.slice(1);
@@ -22,10 +22,10 @@ export function capitalize(str) {
22
22
  * returns the string stripped of whitespace from the left.
23
23
  * @public
24
24
  * @function
25
- * @memberOf me.utils.string
25
+ * @memberof me.utils.string
26
26
  * @name trimLeft
27
- * @param {String} string the string to be trimmed
28
- * @return {string} trimmed string
27
+ * @param {string} str the string to be trimmed
28
+ * @returns {string} trimmed string
29
29
  */
30
30
  export function trimLeft(str) {
31
31
  return str.replace(/^\s+/, "");
@@ -35,10 +35,10 @@ export function trimLeft(str) {
35
35
  * returns the string stripped of whitespace from the right.
36
36
  * @public
37
37
  * @function
38
- * @memberOf me.utils.string
38
+ * @memberof me.utils.string
39
39
  * @name trimRight
40
- * @param {String} string the string to be trimmed
41
- * @return {string} trimmed string
40
+ * @param {string} str the string to be trimmed
41
+ * @returns {string} trimmed string
42
42
  */
43
43
  export function trimRight(str) {
44
44
  return str.replace(/\s+$/, "");
@@ -48,10 +48,10 @@ export function trimRight(str) {
48
48
  * returns true if the given string contains a numeric integer or float value
49
49
  * @public
50
50
  * @function
51
- * @memberOf me.utils.string
51
+ * @memberof me.utils.string
52
52
  * @name isNumeric
53
- * @param {String} string the string to be tested
54
- * @return {Boolean} true if string contains only digits
53
+ * @param {string} str the string to be tested
54
+ * @returns {boolean} true if string contains only digits
55
55
  */
56
56
  export function isNumeric(str) {
57
57
  if (typeof str === "string") {
@@ -64,10 +64,10 @@ export function isNumeric(str) {
64
64
  * returns true if the given string contains a true or false
65
65
  * @public
66
66
  * @function
67
- * @memberOf me.utils.string
67
+ * @memberof me.utils.string
68
68
  * @name isBoolean
69
- * @param {String} string the string to be tested
70
- * @return {Boolean} true if the string is either true or false
69
+ * @param {string} str the string to be tested
70
+ * @returns {boolean} true if the string is either true or false
71
71
  */
72
72
  export function isBoolean(str) {
73
73
  var trimmed = str.trim();
@@ -78,10 +78,10 @@ export function isBoolean(str) {
78
78
  * convert a string to the corresponding hexadecimal value
79
79
  * @public
80
80
  * @function
81
- * @memberOf me.utils.string
81
+ * @memberof me.utils.string
82
82
  * @name toHex
83
- * @param {String} string the string to be converted
84
- * @return {String}
83
+ * @param {string} str the string to be converted
84
+ * @returns {string} the converted hexadecimal value
85
85
  */
86
86
  export function toHex(str) {
87
87
  var res = "", c = 0;
@@ -10,7 +10,7 @@ import { version } from "./../index.js";
10
10
  /**
11
11
  * a collection of utility functions
12
12
  * @namespace utils
13
- * @memberOf me
13
+ * @memberof me
14
14
  */
15
15
 
16
16
  // guid default value
@@ -29,22 +29,22 @@ var utils = {
29
29
  * Get image pixels
30
30
  * @public
31
31
  * @function
32
- * @memberOf me.utils
32
+ * @memberof me.utils
33
33
  * @name getPixels
34
- * @param {Image|Canvas} image Image to read
35
- * @return {ImageData} Canvas ImageData object
34
+ * @param {HTMLImageElement|HTMLCanvasElement} image Image to read
35
+ * @returns {ImageData} ImageData object
36
36
  */
37
- getPixels : function (arg) {
38
- if (arg instanceof HTMLImageElement) {
37
+ getPixels : function (image) {
38
+ if (image instanceof HTMLImageElement) {
39
39
  var _context = CanvasRenderer.getContext2d(
40
- createCanvas(arg.width, arg.height)
40
+ createCanvas(image.width, image.height)
41
41
  );
42
- _context.drawImage(arg, 0, 0);
43
- return _context.getImageData(0, 0, arg.width, arg.height);
42
+ _context.drawImage(image, 0, 0);
43
+ return _context.getImageData(0, 0, image.width, image.height);
44
44
  }
45
45
  else {
46
46
  // canvas !
47
- return arg.getContext("2d").getImageData(0, 0, arg.width, arg.height);
47
+ return image.getContext("2d").getImageData(0, 0, image.width, image.height);
48
48
  }
49
49
  },
50
50
 
@@ -52,11 +52,11 @@ var utils = {
52
52
  * Compare two version strings
53
53
  * @public
54
54
  * @function
55
- * @memberOf me.utils
55
+ * @memberof me.utils
56
56
  * @name checkVersion
57
- * @param {String} first First version string to compare
58
- * @param {String} [second=me.version] Second version string to compare
59
- * @return {Number} comparison result <br>&lt; 0 : first &lt; second<br>
57
+ * @param {string} first First version string to compare
58
+ * @param {string} [second=me.version] Second version string to compare
59
+ * @returns {number} comparison result <br>&lt; 0 : first &lt; second<br>
60
60
  * 0 : first == second<br>
61
61
  * &gt; 0 : first &gt; second
62
62
  * @example
@@ -85,16 +85,16 @@ var utils = {
85
85
  * parse the fragment (hash) from a URL and returns them into
86
86
  * @public
87
87
  * @function
88
- * @memberOf me.utils
88
+ * @memberof me.utils
89
89
  * @name getUriFragment
90
- * @param {String} [url=document.location] an optional params string or URL containing fragment (hash) params to be parsed
91
- * @return {Object} an object representing the deserialized params string.
92
- * @property {Boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
93
- * @property {Boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
94
- * @property {Boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
95
- * @property {Boolean} [webgl=false] force the renderer to WebGL
96
- * @property {Boolean} [debug=false] display the debug panel (if preloaded)
97
- * @property {String} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
90
+ * @param {string} [url=document.location] an optional params string or URL containing fragment (hash) params to be parsed
91
+ * @returns {object} an object representing the deserialized params string.
92
+ * @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
93
+ * @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
94
+ * @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
95
+ * @property {boolean} [webgl=false] force the renderer to WebGL
96
+ * @property {boolean} [debug=false] display the debug panel (if preloaded)
97
+ * @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
98
98
  * @example
99
99
  * // http://www.example.com/index.html#debug&hitbox=true&mytag=value
100
100
  * var UriFragment = me.utils.getUriFragment();