melonjs 10.3.0 → 10.5.1

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 +6 -6
  2. package/dist/melonjs.js +3147 -3293
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3411 -3852
  5. package/dist/melonjs.module.js +3448 -3210
  6. package/package.json +18 -17
  7. package/src/audio/audio.js +29 -30
  8. package/src/camera/camera2d.js +46 -56
  9. package/src/entity/entity.js +30 -36
  10. package/src/game.js +21 -22
  11. package/src/geometries/ellipse.js +40 -46
  12. package/src/geometries/line.js +9 -11
  13. package/src/geometries/poly.js +53 -53
  14. package/src/geometries/rectangle.js +42 -44
  15. package/src/index.js +9 -26
  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 +30 -31
  20. package/src/input/pointerevent.js +26 -26
  21. package/src/lang/deprecated.js +65 -6
  22. package/src/level/level.js +23 -24
  23. package/src/level/tiled/TMXGroup.js +7 -8
  24. package/src/level/tiled/TMXLayer.js +30 -32
  25. package/src/level/tiled/TMXObject.js +21 -21
  26. package/src/level/tiled/TMXTile.js +18 -18
  27. package/src/level/tiled/TMXTileMap.js +39 -44
  28. package/src/level/tiled/TMXTileset.js +12 -15
  29. package/src/level/tiled/TMXTilesetGroup.js +9 -9
  30. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  31. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
  32. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
  33. package/src/level/tiled/renderer/TMXRenderer.js +24 -25
  34. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
  35. package/src/loader/loader.js +14 -15
  36. package/src/loader/loadingscreen.js +2 -4
  37. package/src/math/color.js +47 -66
  38. package/src/math/math.js +15 -16
  39. package/src/math/matrix2.js +53 -58
  40. package/src/math/matrix3.js +56 -62
  41. package/src/math/observable_vector2.js +75 -76
  42. package/src/math/observable_vector3.js +79 -80
  43. package/src/math/vector2.js +91 -92
  44. package/src/math/vector3.js +94 -96
  45. package/src/particles/emitter.js +38 -40
  46. package/src/particles/particle.js +4 -5
  47. package/src/particles/particlecontainer.js +2 -3
  48. package/src/physics/body.js +46 -143
  49. package/src/physics/bounds.js +47 -47
  50. package/src/physics/collision.js +13 -14
  51. package/src/physics/detector.js +18 -17
  52. package/src/physics/quadtree.js +17 -19
  53. package/src/physics/sat.js +26 -26
  54. package/src/physics/world.js +24 -28
  55. package/src/plugin/plugin.js +11 -14
  56. package/src/renderable/GUI.js +41 -46
  57. package/src/renderable/collectable.js +4 -8
  58. package/src/renderable/colorlayer.js +6 -10
  59. package/src/renderable/container.js +87 -72
  60. package/src/renderable/dragndrop.js +224 -0
  61. package/src/renderable/imagelayer.js +25 -31
  62. package/src/renderable/nineslicesprite.js +41 -41
  63. package/src/renderable/renderable.js +114 -125
  64. package/src/renderable/sprite.js +62 -68
  65. package/src/renderable/trigger.js +25 -30
  66. package/src/state/stage.js +13 -17
  67. package/src/state/state.js +26 -27
  68. package/src/system/device.js +74 -75
  69. package/src/system/event.js +71 -72
  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 -54
  74. package/src/text/bitmaptextdata.js +10 -10
  75. package/src/text/glyph.js +3 -0
  76. package/src/text/text.js +44 -49
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +1 -1
  79. package/src/tweens/tween.js +43 -44
  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 +58 -59
  87. package/src/video/renderer.js +49 -53
  88. package/src/video/texture.js +98 -111
  89. package/src/video/texture_cache.js +24 -6
  90. package/src/video/video.js +16 -17
  91. package/src/video/webgl/glshader.js +37 -38
  92. package/src/video/webgl/webgl_compositor.js +31 -32
  93. package/src/video/webgl/webgl_renderer.js +79 -80
  94. package/src/entity/draggable.js +0 -130
  95. package/src/entity/droptarget.js +0 -101
@@ -22,23 +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
- * @param {object} object object on which to apply the tween
28
- * @example
29
- * // add a tween to change the object pos.x and pos.y variable to 200 in 3 seconds
30
- * tween = new me.Tween(myObject.pos).to({
31
- * x: 200,
32
- * y: 200,
33
- * }, {
34
- * duration: 3000,
35
- * easing: me.Tween.Easing.Bounce.Out,
36
- * autoStart : true
37
- * }).onComplete(myFunc);
38
25
  */
39
26
  class Tween {
40
27
 
41
- // 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
+ */
42
41
  constructor ( object ) {
43
42
  this.setProperties(object);
44
43
  }
@@ -120,19 +119,19 @@ class Tween {
120
119
  /**
121
120
  * object properties to be updated and duration
122
121
  * @name to
123
- * @memberof me.Tween
122
+ * @memberof Tween
124
123
  * @public
125
124
  * @function
126
125
  * @param {object} properties hash of properties
127
126
  * @param {object|number} [options] object of tween properties, or a duration if a numeric value is passed
128
127
  * @param {number} [options.duration] tween duration
129
- * @param {me.Tween.Easing} [options.easing] easing function
128
+ * @param {Tween.Easing} [options.easing] easing function
130
129
  * @param {number} [options.delay] delay amount expressed in milliseconds
131
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.
132
131
  * @param {number} [options.repeat] amount of times the tween should be repeated
133
- * @param {me.Tween.Interpolation} [options.interpolation] interpolation function
132
+ * @param {Tween.Interpolation} [options.interpolation] interpolation function
134
133
  * @param {boolean} [options.autoStart] allow this tween to start automatically. Otherwise call me.Tween.start().
135
- * @returns {me.Tween} this instance for object chaining
134
+ * @returns {Tween} this instance for object chaining
136
135
  */
137
136
  to( properties, options ) {
138
137
 
@@ -162,11 +161,11 @@ class Tween {
162
161
  /**
163
162
  * start the tween
164
163
  * @name start
165
- * @memberof me.Tween
164
+ * @memberof Tween
166
165
  * @public
167
166
  * @function
168
167
  * @param {number} [time] the current time when the tween was started
169
- * @returns {me.Tween} this instance for object chaining
168
+ * @returns {Tween} this instance for object chaining
170
169
  */
171
170
  start( time = timer.getTime() ) {
172
171
 
@@ -209,10 +208,10 @@ class Tween {
209
208
  /**
210
209
  * stop the tween
211
210
  * @name stop
212
- * @memberof me.Tween
211
+ * @memberof Tween
213
212
  * @public
214
213
  * @function
215
- * @returns {me.Tween} this instance for object chaining
214
+ * @returns {Tween} this instance for object chaining
216
215
  */
217
216
  stop() {
218
217
  // remove the tween from the world container
@@ -223,11 +222,11 @@ class Tween {
223
222
  /**
224
223
  * delay the tween
225
224
  * @name delay
226
- * @memberof me.Tween
225
+ * @memberof Tween
227
226
  * @public
228
227
  * @function
229
228
  * @param {number} amount delay amount expressed in milliseconds
230
- * @returns {me.Tween} this instance for object chaining
229
+ * @returns {Tween} this instance for object chaining
231
230
  */
232
231
  delay( amount ) {
233
232
 
@@ -239,11 +238,11 @@ class Tween {
239
238
  /**
240
239
  * Repeat the tween
241
240
  * @name repeat
242
- * @memberof me.Tween
241
+ * @memberof Tween
243
242
  * @public
244
243
  * @function
245
244
  * @param {number} times amount of times the tween should be repeated
246
- * @returns {me.Tween} this instance for object chaining
245
+ * @returns {Tween} this instance for object chaining
247
246
  */
248
247
  repeat( times ) {
249
248
 
@@ -256,12 +255,12 @@ class Tween {
256
255
  * Allows the tween to bounce back to their original value when finished.
257
256
  * To be used together with repeat to create endless loops.
258
257
  * @name yoyo
259
- * @memberof me.Tween
258
+ * @memberof Tween
260
259
  * @public
261
260
  * @function
262
- * @see me.Tween#repeat
261
+ * @see Tween#repeat
263
262
  * @param {boolean} yoyo
264
- * @returns {me.Tween} this instance for object chaining
263
+ * @returns {Tween} this instance for object chaining
265
264
  */
266
265
  yoyo( yoyo ) {
267
266
 
@@ -273,11 +272,11 @@ class Tween {
273
272
  /**
274
273
  * set the easing function
275
274
  * @name easing
276
- * @memberof me.Tween
275
+ * @memberof Tween
277
276
  * @public
278
277
  * @function
279
- * @param {me.Tween.Easing} easing easing function
280
- * @returns {me.Tween} this instance for object chaining
278
+ * @param {Tween.Easing} easing easing function
279
+ * @returns {Tween} this instance for object chaining
281
280
  */
282
281
  easing( easing ) {
283
282
  if (typeof easing !== "function") {
@@ -290,11 +289,11 @@ class Tween {
290
289
  /**
291
290
  * set the interpolation function
292
291
  * @name interpolation
293
- * @memberof me.Tween
292
+ * @memberof Tween
294
293
  * @public
295
294
  * @function
296
- * @param {me.Tween.Interpolation} interpolation interpolation function
297
- * @returns {me.Tween} this instance for object chaining
295
+ * @param {Tween.Interpolation} interpolation interpolation function
296
+ * @returns {Tween} this instance for object chaining
298
297
  */
299
298
  interpolation( interpolation ) {
300
299
  this._interpolationFunction = interpolation;
@@ -304,11 +303,11 @@ class Tween {
304
303
  /**
305
304
  * chain the tween
306
305
  * @name chain
307
- * @memberof me.Tween
306
+ * @memberof Tween
308
307
  * @public
309
308
  * @function
310
- * @param {...me.Tween} chainedTween Tween(s) to be chained
311
- * @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
312
311
  */
313
312
  chain() {
314
313
  this._chainedTweens = arguments;
@@ -318,11 +317,11 @@ class Tween {
318
317
  /**
319
318
  * onStart callback
320
319
  * @name onStart
321
- * @memberof me.Tween
320
+ * @memberof Tween
322
321
  * @public
323
322
  * @function
324
323
  * @param {Function} onStartCallback callback
325
- * @returns {me.Tween} this instance for object chaining
324
+ * @returns {Tween} this instance for object chaining
326
325
  */
327
326
  onStart( onStartCallback ) {
328
327
  this._onStartCallback = onStartCallback;
@@ -332,11 +331,11 @@ class Tween {
332
331
  /**
333
332
  * onUpdate callback
334
333
  * @name onUpdate
335
- * @memberof me.Tween
334
+ * @memberof Tween
336
335
  * @public
337
336
  * @function
338
337
  * @param {Function} onUpdateCallback callback
339
- * @returns {me.Tween} this instance for object chaining
338
+ * @returns {Tween} this instance for object chaining
340
339
  */
341
340
  onUpdate( onUpdateCallback ) {
342
341
  this._onUpdateCallback = onUpdateCallback;
@@ -346,11 +345,11 @@ class Tween {
346
345
  /**
347
346
  * onComplete callback
348
347
  * @name onComplete
349
- * @memberof me.Tween
348
+ * @memberof Tween
350
349
  * @public
351
350
  * @function
352
351
  * @param {Function} onCompleteCallback callback
353
- * @returns {me.Tween} this instance for object chaining
352
+ * @returns {Tween} this instance for object chaining
354
353
  */
355
354
  onComplete( onCompleteCallback ) {
356
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.