melonjs 10.3.0 → 10.4.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 (94) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +2419 -3072
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +3417 -3816
  5. package/dist/melonjs.module.js +2737 -3002
  6. package/package.json +16 -16
  7. package/src/audio/audio.js +29 -30
  8. package/src/camera/camera2d.js +46 -56
  9. package/src/entity/draggable.js +12 -13
  10. package/src/entity/droptarget.js +13 -15
  11. package/src/entity/entity.js +30 -36
  12. package/src/game.js +21 -22
  13. package/src/geometries/ellipse.js +40 -46
  14. package/src/geometries/line.js +9 -11
  15. package/src/geometries/poly.js +53 -53
  16. package/src/geometries/rectangle.js +42 -44
  17. package/src/index.js +4 -14
  18. package/src/input/gamepad.js +11 -10
  19. package/src/input/input.js +2 -3
  20. package/src/input/keyboard.js +113 -113
  21. package/src/input/pointer.js +30 -31
  22. package/src/input/pointerevent.js +26 -26
  23. package/src/lang/deprecated.js +25 -6
  24. package/src/level/level.js +23 -24
  25. package/src/level/tiled/TMXGroup.js +7 -8
  26. package/src/level/tiled/TMXLayer.js +30 -32
  27. package/src/level/tiled/TMXObject.js +21 -21
  28. package/src/level/tiled/TMXTile.js +18 -18
  29. package/src/level/tiled/TMXTileMap.js +37 -44
  30. package/src/level/tiled/TMXTileset.js +12 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +9 -9
  32. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  33. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
  34. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
  35. package/src/level/tiled/renderer/TMXRenderer.js +24 -25
  36. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
  37. package/src/loader/loader.js +14 -15
  38. package/src/loader/loadingscreen.js +2 -4
  39. package/src/math/color.js +47 -66
  40. package/src/math/math.js +15 -16
  41. package/src/math/matrix2.js +53 -58
  42. package/src/math/matrix3.js +56 -62
  43. package/src/math/observable_vector2.js +75 -76
  44. package/src/math/observable_vector3.js +79 -80
  45. package/src/math/vector2.js +91 -92
  46. package/src/math/vector3.js +94 -96
  47. package/src/particles/emitter.js +38 -40
  48. package/src/particles/particle.js +4 -5
  49. package/src/particles/particlecontainer.js +2 -3
  50. package/src/physics/body.js +44 -142
  51. package/src/physics/bounds.js +47 -47
  52. package/src/physics/collision.js +13 -14
  53. package/src/physics/detector.js +14 -14
  54. package/src/physics/quadtree.js +17 -19
  55. package/src/physics/sat.js +26 -26
  56. package/src/physics/world.js +24 -28
  57. package/src/plugin/plugin.js +11 -14
  58. package/src/renderable/GUI.js +41 -46
  59. package/src/renderable/collectable.js +4 -8
  60. package/src/renderable/colorlayer.js +6 -10
  61. package/src/renderable/container.js +87 -72
  62. package/src/renderable/imagelayer.js +25 -31
  63. package/src/renderable/nineslicesprite.js +41 -41
  64. package/src/renderable/renderable.js +112 -122
  65. package/src/renderable/sprite.js +62 -68
  66. package/src/renderable/trigger.js +25 -30
  67. package/src/state/stage.js +13 -17
  68. package/src/state/state.js +26 -27
  69. package/src/system/device.js +74 -75
  70. package/src/system/event.js +71 -72
  71. package/src/system/pooling.js +11 -12
  72. package/src/system/save.js +3 -4
  73. package/src/system/timer.js +19 -20
  74. package/src/text/bitmaptext.js +57 -54
  75. package/src/text/bitmaptextdata.js +10 -10
  76. package/src/text/glyph.js +3 -0
  77. package/src/text/text.js +44 -49
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +1 -1
  80. package/src/tweens/tween.js +43 -44
  81. package/src/utils/agent.js +3 -4
  82. package/src/utils/array.js +4 -5
  83. package/src/utils/file.js +3 -4
  84. package/src/utils/function.js +4 -5
  85. package/src/utils/string.js +7 -9
  86. package/src/utils/utils.js +4 -5
  87. package/src/video/canvas/canvas_renderer.js +58 -59
  88. package/src/video/renderer.js +49 -53
  89. package/src/video/texture.js +98 -111
  90. package/src/video/texture_cache.js +2 -2
  91. package/src/video/video.js +15 -16
  92. package/src/video/webgl/glshader.js +37 -38
  93. package/src/video/webgl/webgl_compositor.js +31 -32
  94. package/src/video/webgl/webgl_renderer.js +79 -80
@@ -9,20 +9,16 @@ import state from "./../state/state.js";
9
9
  /**
10
10
  * @classdesc
11
11
  * an object representing the physic world, and responsible for managing and updating all childs and physics
12
- * @class World
13
- * @augments me.Container
14
- * @memberof me
15
- * @param {number} [x=0] position of the container (accessible via the inherited pos.x property)
16
- * @param {number} [y=0] position of the container (accessible via the inherited pos.y property)
17
- * @param {number} [w=me.game.viewport.width] width of the container
18
- * @param {number} [h=me.game.viewport.height] height of the container
12
+ * @augments Container
19
13
  */
20
14
  class World extends Container {
21
15
  /**
22
- * @ignore
16
+ * @param {number} [x=0] position of the container (accessible via the inherited pos.x property)
17
+ * @param {number} [y=0] position of the container (accessible via the inherited pos.y property)
18
+ * @param {number} [width=game.viewport.width] width of the container
19
+ * @param {number} [height=game.viewport.height] height of the container
23
20
  */
24
21
  constructor(x = 0, y = 0, width = Infinity, height = Infinity) {
25
-
26
22
  // call the super constructor
27
23
  super(x, y, width, height, true);
28
24
 
@@ -36,21 +32,21 @@ class World extends Container {
36
32
  * the rate at which the game world is updated,
37
33
  * may be greater than or lower than the display fps
38
34
  * @public
39
- * @type {me.Vector2d}
35
+ * @type {Vector2d}
40
36
  * @default 60
41
37
  * @name fps
42
- * @memberof me.World
43
- * @see me.timer.maxfps
38
+ * @memberof World
39
+ * @see timer.maxfps
44
40
  */
45
41
  this.fps = 60;
46
42
 
47
43
  /**
48
44
  * world gravity
49
45
  * @public
50
- * @type {me.Vector2d}
46
+ * @type {Vector2d}
51
47
  * @default <0,0.98>
52
48
  * @name gravity
53
- * @memberof me.World
49
+ * @memberof World
54
50
  */
55
51
  this.gravity = new Vector2d(0, 0.98);
56
52
 
@@ -64,14 +60,14 @@ class World extends Container {
64
60
  * property to your layer (in Tiled).
65
61
  * @type {boolean}
66
62
  * @default false
67
- * @memberof me.World
63
+ * @memberof World
68
64
  */
69
65
  this.preRender = false;
70
66
 
71
67
  /**
72
68
  * the active physic bodies in this simulation
73
69
  * @name bodies
74
- * @memberof me.World
70
+ * @memberof World
75
71
  * @public
76
72
  * @type {Set}
77
73
  */
@@ -80,9 +76,9 @@ class World extends Container {
80
76
  /**
81
77
  * the instance of the game world quadtree used for broadphase
82
78
  * @name broadphase
83
- * @memberof me.World
79
+ * @memberof World
84
80
  * @public
85
- * @type {me.QuadTree}
81
+ * @type {QuadTree}
86
82
  */
87
83
  this.broadphase = new QuadTree(this.getBounds().clone(), collision.maxChildren, collision.maxDepth);
88
84
 
@@ -99,7 +95,7 @@ class World extends Container {
99
95
  /**
100
96
  * reset the game world
101
97
  * @name reset
102
- * @memberof me.World
98
+ * @memberof World
103
99
  * @function
104
100
  */
105
101
  reset() {
@@ -120,11 +116,11 @@ class World extends Container {
120
116
  /**
121
117
  * Add a physic body to the game world
122
118
  * @name addBody
123
- * @memberof me.World
124
- * @see me.Container.addChild
119
+ * @memberof World
120
+ * @see Container.addChild
125
121
  * @function
126
- * @param {me.Body} body
127
- * @returns {me.World} this game world
122
+ * @param {Body} body
123
+ * @returns {World} this game world
128
124
  */
129
125
  addBody(body) {
130
126
  //add it to the list of active body
@@ -135,11 +131,11 @@ class World extends Container {
135
131
  /**
136
132
  * Remove a physic body from the game world
137
133
  * @name removeBody
138
- * @memberof me.World
139
- * @see me.Container.removeChild
134
+ * @memberof World
135
+ * @see Container.removeChild
140
136
  * @function
141
- * @param {me.Body} body
142
- * @returns {me.World} this game world
137
+ * @param {Body} body
138
+ * @returns {World} this game world
143
139
  */
144
140
  removeBody(body) {
145
141
  //remove from the list of active body
@@ -150,7 +146,7 @@ class World extends Container {
150
146
  /**
151
147
  * update the game world
152
148
  * @name reset
153
- * @memberof me.World
149
+ * @memberof World
154
150
  * @function
155
151
  * @param {number} dt the time passed since the last frame update
156
152
  * @returns {boolean} true if the word is dirty
@@ -3,9 +3,8 @@ import { version } from "./../index.js";
3
3
 
4
4
  /**
5
5
  * This namespace is a container for all registered plugins.
6
- * @see me.plugin.register
7
- * @namespace me.plugins
8
- * @memberof me
6
+ * @see plugin.register
7
+ * @namespace plugins
9
8
  */
10
9
  export var plugins = {};
11
10
 
@@ -19,7 +18,7 @@ class BasePlugin {
19
18
  * @public
20
19
  * @type {string}
21
20
  * @default "__VERSION__"
22
- * @name me.plugin.Base#version
21
+ * @name plugin.Base#version
23
22
  */
24
23
  this.version = "__VERSION__";
25
24
  }
@@ -27,25 +26,23 @@ class BasePlugin {
27
26
 
28
27
  /**
29
28
  * @namespace plugin
30
- * @memberof me
31
29
  */
32
30
  export var plugin = {
33
31
 
34
32
  /**
35
33
  * a base Object for plugin <br>
36
34
  * plugin must be installed using the register function
37
- * @see me.plugin
35
+ * @see plugin
38
36
  * @class
39
- * @augments me.Object
40
- * @name plugin.Base
41
- * @memberof me
37
+ * @name Base
38
+ * @memberof plugin
42
39
  */
43
40
  Base : BasePlugin,
44
41
 
45
42
  /**
46
43
  * patch a melonJS function
47
44
  * @name patch
48
- * @memberof me.plugin
45
+ * @memberof plugin
49
46
  * @public
50
47
  * @function
51
48
  * @param {object} proto target object
@@ -65,7 +62,7 @@ export var plugin = {
65
62
  if (typeof proto.prototype !== "undefined") {
66
63
  proto = proto.prototype;
67
64
  }
68
- // reuse the logic behind me.Object.extend
65
+ // reuse the logic behind object extends
69
66
  if (typeof(proto[name]) === "function") {
70
67
  // save the original function
71
68
  var _parent = proto[name];
@@ -90,11 +87,11 @@ export var plugin = {
90
87
  /**
91
88
  * Register a plugin.
92
89
  * @name register
93
- * @memberof me.plugin
94
- * @see me.plugin.Base
90
+ * @memberof plugin
91
+ * @see Base
95
92
  * @public
96
93
  * @function
97
- * @param {me.plugin.Base} pluginObj Plugin object to instantiate and register
94
+ * @param {plugin.Base} pluginObj Plugin object to instantiate and register
98
95
  * @param {string} name
99
96
  * @param {object} [...arguments] all extra parameters will be passed to the plugin constructor
100
97
  * @example
@@ -9,43 +9,38 @@ import { registerPointerEvent, releasePointerEvent} from "./../input/input.js";
9
9
  * A very basic object to manage GUI elements <br>
10
10
  * The object simply register on the "pointerdown" <br>
11
11
  * or "touchstart" event and call the onClick function"
12
- * @class GUI_Object
13
- * @augments me.Sprite
14
- * @memberof me
15
- * @param {number} x the x coordinate of the GUI Object
16
- * @param {number} y the y coordinate of the GUI Object
17
- * @param {object} settings See {@link me.Sprite}
18
- * @example
19
- * // create a basic GUI Object
20
- * class myButton extends GUI_Object {
21
- * constructor(x, y) {
22
- * var settings = {}
23
- * settings.image = "button";
24
- * settings.framewidth = 100;
25
- * settings.frameheight = 50;
26
- * // super constructor
27
- * super(x, y, settings);
28
- * // define the object z order
29
- * this.pos.z = 4;
30
- * }
31
- *
32
- * // output something in the console
33
- * // when the object is clicked
34
- * onClick:function (event) {
35
- * console.log("clicked!");
36
- * // don't propagate the event
37
- * return false;
38
- * }
39
- * });
40
- *
41
- * // add the object at pos (10,10)
42
- * me.game.world.addChild(new myButton(10,10));
12
+ * @augments Sprite
43
13
  */
44
-
45
14
  class GUI_Object extends Sprite {
46
-
47
15
  /**
48
- * @ignore
16
+ * @param {number} x the x coordinate of the GUI Object
17
+ * @param {number} y the y coordinate of the GUI Object
18
+ * @param {object} settings See {@link Sprite}
19
+ * @example
20
+ * // create a basic GUI Object
21
+ * class myButton extends GUI_Object {
22
+ * constructor(x, y) {
23
+ * var settings = {}
24
+ * settings.image = "button";
25
+ * settings.framewidth = 100;
26
+ * settings.frameheight = 50;
27
+ * // super constructor
28
+ * super(x, y, settings);
29
+ * // define the object z order
30
+ * this.pos.z = 4;
31
+ * }
32
+ *
33
+ * // output something in the console
34
+ * // when the object is clicked
35
+ * onClick:function (event) {
36
+ * console.log("clicked!");
37
+ * // don't propagate the event
38
+ * return false;
39
+ * }
40
+ * });
41
+ *
42
+ * // add the object at pos (10,10)
43
+ * me.game.world.addChild(new myButton(10,10));
49
44
  */
50
45
  constructor(x, y, settings) {
51
46
 
@@ -57,7 +52,7 @@ class GUI_Object extends Sprite {
57
52
  * @public
58
53
  * @type {boolean}
59
54
  * @default true
60
- * @name me.GUI_Object#isClickable
55
+ * @name GUI_Object#isClickable
61
56
  */
62
57
  this.isClickable = true;
63
58
 
@@ -65,7 +60,7 @@ class GUI_Object extends Sprite {
65
60
  * Tap and hold threshold timeout in ms
66
61
  * @type {number}
67
62
  * @default 250
68
- * @name me.GUI_Object#holdThreshold
63
+ * @name GUI_Object#holdThreshold
69
64
  */
70
65
  this.holdThreshold = 250;
71
66
 
@@ -74,7 +69,7 @@ class GUI_Object extends Sprite {
74
69
  * @public
75
70
  * @type {boolean}
76
71
  * @default false
77
- * @name me.GUI_Object#isHoldable
72
+ * @name GUI_Object#isHoldable
78
73
  */
79
74
  this.isHoldable = false;
80
75
 
@@ -83,7 +78,7 @@ class GUI_Object extends Sprite {
83
78
  * @public
84
79
  * @type {boolean}
85
80
  * @default false
86
- * @name me.GUI_Object#hover
81
+ * @name GUI_Object#hover
87
82
  */
88
83
  this.hover = false;
89
84
 
@@ -121,10 +116,10 @@ class GUI_Object extends Sprite {
121
116
  /**
122
117
  * function called when the object is pressed (to be extended)
123
118
  * @name onClick
124
- * @memberof me.GUI_Object.prototype
119
+ * @memberof GUI_Object.prototype
125
120
  * @public
126
121
  * @function
127
- * @param {me.Pointer} event the event object
122
+ * @param {Pointer} event the event object
128
123
  * @returns {boolean} return false if we need to stop propagating the event
129
124
  */
130
125
  onClick(/* event */) {
@@ -144,10 +139,10 @@ class GUI_Object extends Sprite {
144
139
  /**
145
140
  * function called when the pointer is over the object
146
141
  * @name onOver
147
- * @memberof me.GUI_Object.prototype
142
+ * @memberof GUI_Object.prototype
148
143
  * @public
149
144
  * @function
150
- * @param {me.Pointer} event the event object
145
+ * @param {Pointer} event the event object
151
146
  */
152
147
  onOver(/* event */) {}
153
148
 
@@ -165,10 +160,10 @@ class GUI_Object extends Sprite {
165
160
  /**
166
161
  * function called when the pointer is leaving the object area
167
162
  * @name onOut
168
- * @memberof me.GUI_Object.prototype
163
+ * @memberof GUI_Object.prototype
169
164
  * @public
170
165
  * @function
171
- * @param {me.Pointer} event the event object
166
+ * @param {Pointer} event the event object
172
167
  */
173
168
  onOut(/* event */) {
174
169
 
@@ -190,7 +185,7 @@ class GUI_Object extends Sprite {
190
185
  /**
191
186
  * function called when the object is pressed and released (to be extended)
192
187
  * @name onRelease
193
- * @memberof me.GUI_Object.prototype
188
+ * @memberof GUI_Object.prototype
194
189
  * @public
195
190
  * @function
196
191
  * @returns {boolean} return false if we need to stop propagating the event
@@ -215,7 +210,7 @@ class GUI_Object extends Sprite {
215
210
  * function called when the object is pressed and held<br>
216
211
  * to be extended <br>
217
212
  * @name onHold
218
- * @memberof me.GUI_Object.prototype
213
+ * @memberof GUI_Object.prototype
219
214
  * @public
220
215
  * @function
221
216
  */
@@ -6,17 +6,13 @@ import collision from "./../physics/collision.js";
6
6
  /**
7
7
  * @classdesc
8
8
  * a basic collectable helper class for immovable object (e.g. a coin)
9
- * @class Collectable
10
- * @augments me.Sprite
11
- * @memberof me
12
- * @param {number} x the x coordinates of the collectable
13
- * @param {number} y the y coordinates of the collectable
14
- * @param {object} settings See {@link me.Sprite}
9
+ * @augments Sprite
15
10
  */
16
-
17
11
  class Collectable extends Sprite {
18
12
  /**
19
- * @ignore
13
+ * @param {number} x the x coordinates of the collectable
14
+ * @param {number} y the y coordinates of the collectable
15
+ * @param {object} settings See {@link Sprite}
20
16
  */
21
17
  constructor(x, y, settings) {
22
18
 
@@ -6,17 +6,13 @@ import Renderable from "./renderable.js";
6
6
  /**
7
7
  * @classdesc
8
8
  * a generic Color Layer Object. Fills the entire Canvas with the color not just the container the object belongs to.
9
- * @class ColorLayer
10
- * @augments me.Renderable
11
- * @memberof me
12
- * @param {string} name Layer name
13
- * @param {me.Color|string} color CSS color
14
- * @param {number} [z = 0] z-index position
9
+ * @augments Renderable
15
10
  */
16
11
  class ColorLayer extends Renderable {
17
-
18
12
  /**
19
- * @ignore
13
+ * @param {string} name Layer name
14
+ * @param {Color|string} color CSS color
15
+ * @param {number} [z = 0] z-index position
20
16
  */
21
17
  constructor(name, color, z) {
22
18
  // parent constructor
@@ -25,9 +21,9 @@ class ColorLayer extends Renderable {
25
21
  /**
26
22
  * the layer color component
27
23
  * @public
28
- * @type {me.Color}
24
+ * @type {Color}
29
25
  * @name color
30
- * @memberof me.ColorLayer#
26
+ * @memberof ColorLayer#
31
27
  */
32
28
  this.color = pool.pull("Color").parseCSS(color);
33
29