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.
- package/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- 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
|
-
* @
|
|
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
|
-
* @
|
|
17
|
+
* @memberof me.utils.file
|
|
18
18
|
* @name getBasename
|
|
19
|
-
* @param {
|
|
20
|
-
* @
|
|
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
|
-
* @
|
|
30
|
+
* @memberof me.utils.file
|
|
31
31
|
* @name getExtension
|
|
32
|
-
* @param {
|
|
33
|
-
* @
|
|
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);
|
package/src/utils/function.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* a collection of utility functions
|
|
3
3
|
* @namespace me.utils.function
|
|
4
|
-
* @
|
|
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
|
-
* @
|
|
11
|
+
* @memberof me.utils.function
|
|
13
12
|
* @name defer
|
|
14
|
-
* @param {Function}
|
|
15
|
-
* @param {
|
|
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
|
-
* @
|
|
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
|
-
* @
|
|
32
|
+
* @memberof me.utils.function
|
|
34
33
|
* @name throttle
|
|
35
34
|
* @param {Function} fn the function to be throttled.
|
|
36
|
-
* @param {
|
|
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;
|
package/src/utils/string.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* a collection of string utility functions
|
|
3
3
|
* @namespace me.utils.string
|
|
4
|
-
* @
|
|
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
|
-
* @
|
|
12
|
+
* @memberof me.utils.string
|
|
13
13
|
* @name capitalize
|
|
14
|
-
* @param {
|
|
15
|
-
* @
|
|
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
|
-
* @
|
|
25
|
+
* @memberof me.utils.string
|
|
26
26
|
* @name trimLeft
|
|
27
|
-
* @param {
|
|
28
|
-
* @
|
|
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
|
-
* @
|
|
38
|
+
* @memberof me.utils.string
|
|
39
39
|
* @name trimRight
|
|
40
|
-
* @param {
|
|
41
|
-
* @
|
|
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
|
-
* @
|
|
51
|
+
* @memberof me.utils.string
|
|
52
52
|
* @name isNumeric
|
|
53
|
-
* @param {
|
|
54
|
-
* @
|
|
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
|
-
* @
|
|
67
|
+
* @memberof me.utils.string
|
|
68
68
|
* @name isBoolean
|
|
69
|
-
* @param {
|
|
70
|
-
* @
|
|
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
|
-
* @
|
|
81
|
+
* @memberof me.utils.string
|
|
82
82
|
* @name toHex
|
|
83
|
-
* @param {
|
|
84
|
-
* @
|
|
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;
|
package/src/utils/utils.js
CHANGED
|
@@ -10,7 +10,7 @@ import { version } from "./../index.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* a collection of utility functions
|
|
12
12
|
* @namespace utils
|
|
13
|
-
* @
|
|
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
|
-
* @
|
|
32
|
+
* @memberof me.utils
|
|
33
33
|
* @name getPixels
|
|
34
|
-
* @param {
|
|
35
|
-
* @
|
|
34
|
+
* @param {HTMLImageElement|HTMLCanvasElement} image Image to read
|
|
35
|
+
* @returns {ImageData} ImageData object
|
|
36
36
|
*/
|
|
37
|
-
getPixels : function (
|
|
38
|
-
if (
|
|
37
|
+
getPixels : function (image) {
|
|
38
|
+
if (image instanceof HTMLImageElement) {
|
|
39
39
|
var _context = CanvasRenderer.getContext2d(
|
|
40
|
-
createCanvas(
|
|
40
|
+
createCanvas(image.width, image.height)
|
|
41
41
|
);
|
|
42
|
-
_context.drawImage(
|
|
43
|
-
return _context.getImageData(0, 0,
|
|
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
|
|
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
|
-
* @
|
|
55
|
+
* @memberof me.utils
|
|
56
56
|
* @name checkVersion
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
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>< 0 : first < second<br>
|
|
60
60
|
* 0 : first == second<br>
|
|
61
61
|
* > 0 : first > 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
|
-
* @
|
|
88
|
+
* @memberof me.utils
|
|
89
89
|
* @name getUriFragment
|
|
90
|
-
* @param {
|
|
91
|
-
* @
|
|
92
|
-
* @property {
|
|
93
|
-
* @property {
|
|
94
|
-
* @property {
|
|
95
|
-
* @property {
|
|
96
|
-
* @property {
|
|
97
|
-
* @property {
|
|
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();
|