melonjs 10.1.0 → 10.2.2

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 (92) hide show
  1. package/README.md +6 -12
  2. package/dist/melonjs.js +3119 -2857
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +2590 -2490
  5. package/dist/melonjs.module.js +2698 -2470
  6. package/package.json +10 -11
  7. package/src/audio/audio.js +43 -43
  8. package/src/camera/camera2d.js +55 -77
  9. package/src/entity/draggable.js +18 -17
  10. package/src/entity/droptarget.js +19 -18
  11. package/src/entity/entity.js +22 -26
  12. package/src/game.js +3 -3
  13. package/src/index.js +15 -11
  14. package/src/input/gamepad.js +13 -13
  15. package/src/input/input.js +1 -1
  16. package/src/input/keyboard.js +14 -16
  17. package/src/input/pointer.js +42 -35
  18. package/src/input/pointerevent.js +25 -33
  19. package/src/lang/deprecated.js +3 -3
  20. package/src/level/level.js +24 -16
  21. package/src/level/tiled/TMXGroup.js +6 -6
  22. package/src/level/tiled/TMXLayer.js +31 -31
  23. package/src/level/tiled/TMXObject.js +19 -19
  24. package/src/level/tiled/TMXTile.js +11 -12
  25. package/src/level/tiled/TMXTileMap.js +23 -21
  26. package/src/level/tiled/TMXTileset.js +13 -13
  27. package/src/level/tiled/TMXTilesetGroup.js +4 -4
  28. package/src/level/tiled/TMXUtils.js +13 -11
  29. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  30. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  31. package/src/level/tiled/renderer/TMXRenderer.js +17 -17
  32. package/src/loader/loader.js +31 -27
  33. package/src/loader/loadingscreen.js +40 -72
  34. package/src/math/color.js +45 -64
  35. package/src/math/math.js +17 -17
  36. package/src/math/matrix2.js +46 -46
  37. package/src/math/matrix3.js +64 -64
  38. package/src/math/observable_vector2.js +45 -57
  39. package/src/math/observable_vector3.js +56 -70
  40. package/src/math/vector2.js +60 -59
  41. package/src/math/vector3.js +65 -64
  42. package/src/particles/emitter.js +53 -55
  43. package/src/particles/particle.js +1 -1
  44. package/src/physics/body.js +45 -51
  45. package/src/physics/bounds.js +36 -36
  46. package/src/physics/collision.js +15 -16
  47. package/src/physics/detector.js +10 -11
  48. package/src/physics/quadtree.js +19 -17
  49. package/src/physics/sat.js +17 -17
  50. package/src/physics/world.js +13 -10
  51. package/src/plugin/plugin.js +6 -6
  52. package/src/renderable/GUI.js +13 -18
  53. package/src/renderable/collectable.js +3 -3
  54. package/src/renderable/colorlayer.js +4 -4
  55. package/src/renderable/container.js +65 -46
  56. package/src/renderable/imagelayer.js +32 -31
  57. package/src/renderable/nineslicesprite.js +211 -0
  58. package/src/renderable/renderable.js +69 -67
  59. package/src/renderable/sprite.js +57 -43
  60. package/src/renderable/trigger.js +14 -15
  61. package/src/shapes/ellipse.js +27 -26
  62. package/src/shapes/line.js +8 -7
  63. package/src/shapes/poly.js +33 -31
  64. package/src/shapes/rectangle.js +50 -96
  65. package/src/state/stage.js +8 -8
  66. package/src/state/state.js +56 -56
  67. package/src/system/device.js +97 -84
  68. package/src/system/event.js +72 -72
  69. package/src/system/pooling.js +14 -14
  70. package/src/system/save.js +6 -3
  71. package/src/system/timer.js +20 -20
  72. package/src/text/bitmaptext.js +27 -33
  73. package/src/text/bitmaptextdata.js +9 -9
  74. package/src/text/text.js +118 -59
  75. package/src/tweens/easing.js +4 -4
  76. package/src/tweens/interpolation.js +4 -4
  77. package/src/tweens/tween.js +37 -27
  78. package/src/utils/agent.js +9 -8
  79. package/src/utils/array.js +4 -4
  80. package/src/utils/file.js +4 -4
  81. package/src/utils/function.js +5 -5
  82. package/src/utils/string.js +12 -12
  83. package/src/utils/utils.js +19 -19
  84. package/src/video/canvas/canvas_renderer.js +90 -90
  85. package/src/video/renderer.js +40 -39
  86. package/src/video/texture.js +85 -76
  87. package/src/video/texture_cache.js +11 -0
  88. package/src/video/video.js +30 -30
  89. package/src/video/webgl/buffer/vertex.js +9 -1
  90. package/src/video/webgl/glshader.js +20 -20
  91. package/src/video/webgl/webgl_compositor.js +47 -37
  92. package/src/video/webgl/webgl_renderer.js +104 -104
@@ -11,18 +11,12 @@ import { world } from "./../game.js";
11
11
 
12
12
 
13
13
  /**
14
- * a Generic Body Object with some physic properties and behavior functionality<br>
15
- The body object is attached as a member of a Renderable. The Body object can handle movements of the parent with
16
- the body.update call. It is important to know that when body.update is called there are several things that happen related to
17
- the movement and positioning of the parent renderable object. 1) The force/gravity/friction parameters are used
18
- to calculate a new velocity and 2) the parent position is updated by adding this to the parent.pos (position me.Vector2d)
19
- value. Thus Affecting the movement of the parent. Look at the source code for /src/physics/body.js:update (me.Body.update) for
20
- a better understanding.
14
+ * a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
21
15
  * @class Body
22
16
  * @memberOf me
23
17
  * @constructor
24
18
  * @param {me.Renderable} ancestor the parent object this body is attached to
25
- * @param {me.Rect|me.Rect[]|me.Polygon|me.Polygon[]|me.Line|me.Line[]|me.Ellipse|me.Ellipse[]|me.Bounds|me.Bounds[]|Object} [shapes] a initial shape, list of shapes, or JSON object defining the body
19
+ * @param {me.Rect|me.Rect[]|me.Polygon|me.Polygon[]|me.Line|me.Line[]|me.Ellipse|me.Ellipse[]|me.Bounds|me.Bounds[]|object} [shapes] a initial shape, list of shapes, or JSON object defining the body
26
20
  * @param {Function} [onBodyUpdate] callback for when the body is updated (e.g. add/remove shapes)
27
21
  */
28
22
  class Body {
@@ -33,7 +27,7 @@ class Body {
33
27
  * a reference to the parent object that contains this body,
34
28
  * or undefined if it has not been added to one.
35
29
  * @public
36
- * @type me.Renderable
30
+ * @type {me.Renderable}
37
31
  * @default undefined
38
32
  * @name me.Body#ancestor
39
33
  */
@@ -65,7 +59,7 @@ class Body {
65
59
  * The body collision mask, that defines what should collide with what.<br>
66
60
  * (by default will collide with all entities)
67
61
  * @ignore
68
- * @type Number
62
+ * @type {number}
69
63
  * @default me.collision.types.ALL_OBJECT
70
64
  * @name collisionMask
71
65
  * @see me.collision.types
@@ -76,7 +70,7 @@ class Body {
76
70
  /**
77
71
  * define the collision type of the body for collision filtering
78
72
  * @public
79
- * @type Number
73
+ * @type {number}
80
74
  * @default me.collision.types.ENEMY_OBJECT
81
75
  * @name collisionType
82
76
  * @see me.collision.types
@@ -90,7 +84,7 @@ class Body {
90
84
  /**
91
85
  * body velocity
92
86
  * @public
93
- * @type me.Vector2d
87
+ * @type {me.Vector2d}
94
88
  * @default <0,0>
95
89
  * @name vel
96
90
  * @memberOf me.Body
@@ -104,7 +98,7 @@ class Body {
104
98
  * body force or acceleration (automatically) applied to the body.
105
99
  * when defining a force, user should also define a max velocity
106
100
  * @public
107
- * @type me.Vector2d
101
+ * @type {me.Vector2d}
108
102
  * @default <0,0>
109
103
  * @name force
110
104
  * @see me.Body.setMaxVelocity
@@ -135,7 +129,7 @@ class Body {
135
129
  /**
136
130
  * body friction
137
131
  * @public
138
- * @type me.Vector2d
132
+ * @type {me.Vector2d}
139
133
  * @default <0,0>
140
134
  * @name friction
141
135
  * @memberOf me.Body
@@ -149,7 +143,7 @@ class Body {
149
143
  * the body bouciness level when colliding with other solid bodies :
150
144
  * a value of 0 will not bounce, a value of 1 will fully rebound.
151
145
  * @public
152
- * @type {Number}
146
+ * @type {number}
153
147
  * @default 0
154
148
  * @name bounce
155
149
  * @memberOf me.Body
@@ -159,7 +153,7 @@ class Body {
159
153
  /**
160
154
  * the body mass
161
155
  * @public
162
- * @type {Number}
156
+ * @type {number}
163
157
  * @default 1
164
158
  * @name mass
165
159
  * @memberOf me.Body
@@ -169,7 +163,7 @@ class Body {
169
163
  /**
170
164
  * max velocity (to limit body velocity)
171
165
  * @public
172
- * @type me.Vector2d
166
+ * @type {me.Vector2d}
173
167
  * @default <490,490>
174
168
  * @name maxVel
175
169
  * @memberOf me.Body
@@ -185,7 +179,7 @@ class Body {
185
179
  * either this body is a static body or not
186
180
  * @readonly
187
181
  * @public
188
- * @type Boolean
182
+ * @type {boolean}
189
183
  * @default false
190
184
  * @name isStatic
191
185
  * @memberOf me.Body
@@ -197,7 +191,7 @@ class Body {
197
191
  * The degree to which this body is affected by the world gravity
198
192
  * @public
199
193
  * @see me.World.gravity
200
- * @type Number
194
+ * @type {number}
201
195
  * @default 1.0
202
196
  * @name gravityScale
203
197
  * @memberOf me.Body
@@ -208,7 +202,7 @@ class Body {
208
202
  * If true this body won't be affected by the world gravity
209
203
  * @public
210
204
  * @see me.World.gravity
211
- * @type Boolean
205
+ * @type {boolean}
212
206
  * @default false
213
207
  * @name ignoreGravity
214
208
  * @memberOf me.Body
@@ -221,7 +215,7 @@ class Body {
221
215
  * false if the object is standing on something<br>
222
216
  * @readonly
223
217
  * @public
224
- * @type Boolean
218
+ * @type {boolean}
225
219
  * @default false
226
220
  * @name falling
227
221
  * @memberOf me.Body
@@ -233,7 +227,7 @@ class Body {
233
227
  * equal true if the body is jumping<br>
234
228
  * @readonly
235
229
  * @public
236
- * @type Boolean
230
+ * @type {boolean}
237
231
  * @default false
238
232
  * @name jumping
239
233
  * @memberOf me.Body
@@ -269,7 +263,7 @@ class Body {
269
263
  * @memberOf me.Body
270
264
  * @public
271
265
  * @function
272
- * @param {Boolean} [isStatic=true]
266
+ * @param {boolean} [isStatic=true]
273
267
  */
274
268
  setStatic(isStatic = true) {
275
269
  this.isStatic = isStatic === true;
@@ -282,8 +276,8 @@ class Body {
282
276
  * @memberOf me.Body
283
277
  * @public
284
278
  * @function
285
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse|me.Bounds|Object} shape a shape or JSON object
286
- * @return {Number} the shape array length
279
+ * @param {me.Rect|me.Polygon|me.Line|me.Ellipse|me.Bounds|object} shape a shape or JSON object
280
+ * @returns {number} the shape array length
287
281
  * @example
288
282
  * // add a rectangle shape
289
283
  * this.body.addShape(new me.Rect(0, 0, image.width, image.height));
@@ -337,7 +331,7 @@ class Body {
337
331
  * @public
338
332
  * @function
339
333
  * @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
340
- * @param {Number} [index=0] the shape object for which to set the vertices
334
+ * @param {number} [index=0] the shape object for which to set the vertices
341
335
  * @param {boolean} [clear=true] either to reset the body definition before adding the new vertices
342
336
  */
343
337
  setVertices(vertices, index = 0, clear = true) {
@@ -364,7 +358,7 @@ class Body {
364
358
  * @public
365
359
  * @function
366
360
  * @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
367
- * @param {Number} [index=0] the shape object for which to set the vertices
361
+ * @param {number} [index=0] the shape object for which to set the vertices
368
362
  */
369
363
  addVertices(vertices, index = 0) {
370
364
  this.setVertices(vertices, index, false);
@@ -377,10 +371,10 @@ class Body {
377
371
  * @memberOf me.Body
378
372
  * @public
379
373
  * @function
380
- * @param {Object} json a JSON object as exported from a Physics Editor tool
381
- * @param {String} [id] an optional shape identifier within the given the json object
374
+ * @param {object} json a JSON object as exported from a Physics Editor tool
375
+ * @param {string} [id] an optional shape identifier within the given the json object
382
376
  * @see https://www.codeandweb.com/physicseditor
383
- * @return {Number} how many shapes were added to the body
377
+ * @returns {number} how many shapes were added to the body
384
378
  * @example
385
379
  * // define the body based on the banana shape
386
380
  * this.body.fromJSON(me.loader.getJSON("shapesdef").banana);
@@ -421,8 +415,8 @@ class Body {
421
415
  * @memberOf me.Body
422
416
  * @public
423
417
  * @function
424
- * @param {Number} [index=0] the shape object at the specified index
425
- * @return {me.Polygon|me.Line|me.Ellipse} shape a shape object if defined
418
+ * @param {number} [index=0] the shape object at the specified index
419
+ * @returns {me.Polygon|me.Line|me.Ellipse} shape a shape object if defined
426
420
  */
427
421
  getShape(index) {
428
422
  return this.shapes[index || 0];
@@ -433,7 +427,7 @@ class Body {
433
427
  * @name getBounds
434
428
  * @memberOf me.Body
435
429
  * @function
436
- * @return {me.Bounds} bounding box Rectangle object
430
+ * @returns {me.Bounds} bounding box Rectangle object
437
431
  */
438
432
  getBounds() {
439
433
  return this.bounds;
@@ -446,7 +440,7 @@ class Body {
446
440
  * @public
447
441
  * @function
448
442
  * @param {me.Polygon|me.Line|me.Ellipse} shape a shape object
449
- * @return {Number} the shape array length
443
+ * @returns {number} the shape array length
450
444
  */
451
445
  removeShape(shape) {
452
446
  // clear the current bounds
@@ -467,8 +461,8 @@ class Body {
467
461
  * @memberOf me.Body
468
462
  * @public
469
463
  * @function
470
- * @param {Number} index the shape object at the specified index
471
- * @return {Number} the shape array length
464
+ * @param {number} index the shape object at the specified index
465
+ * @returns {number} the shape array length
472
466
  */
473
467
  removeShapeAt(index) {
474
468
  return this.removeShape(this.getShape(index));
@@ -483,7 +477,7 @@ class Body {
483
477
  * @public
484
478
  * @function
485
479
  * @see me.collision.types
486
- * @param {Number} [bitmask = me.collision.types.ALL_OBJECT] the collision mask
480
+ * @param {number} [bitmask = me.collision.types.ALL_OBJECT] the collision mask
487
481
  * @example
488
482
  * // filter collision detection with collision shapes, enemies and collectables
489
483
  * myEntity.body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
@@ -502,7 +496,7 @@ class Body {
502
496
  * @public
503
497
  * @function
504
498
  * @see me.collision.types
505
- * @param {Number} type the collision type
499
+ * @param {number} type the collision type
506
500
  * @example
507
501
  * // set the body collision type
508
502
  * myEntity.body.collisionType = me.collision.types.PLAYER_OBJECT;
@@ -564,7 +558,7 @@ class Body {
564
558
  * @memberOf me.Body.prototype
565
559
  * @function
566
560
  * @param {Function} callback fnction to execute on each element
567
- * @param {Object} [thisArg] value to use as this(i.e reference Object) when executing callback.
561
+ * @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
568
562
  * @example
569
563
  * // iterate through all shapes of the physic body
570
564
  * mySprite.body.forEach((shape) => {
@@ -601,7 +595,7 @@ class Body {
601
595
  * @memberOf me.Body
602
596
  * @function
603
597
  * @param {me.Vector2d} point
604
- * @return {boolean} true if contains
598
+ * @returns {boolean} true if contains
605
599
  */
606
600
 
607
601
  /**
@@ -609,9 +603,9 @@ class Body {
609
603
  * @name contains
610
604
  * @memberOf me.Body
611
605
  * @function
612
- * @param {Number} x x coordinate
613
- * @param {Number} y y coordinate
614
- * @return {boolean} true if contains
606
+ * @param {number} x x coordinate
607
+ * @param {number} y y coordinate
608
+ * @returns {boolean} true if contains
615
609
  */
616
610
  contains() {
617
611
  var _x, _y;
@@ -643,9 +637,9 @@ class Body {
643
637
  * @name rotate
644
638
  * @memberOf me.Body
645
639
  * @function
646
- * @param {Number} angle The angle to rotate (in radians)
640
+ * @param {number} angle The angle to rotate (in radians)
647
641
  * @param {me.Vector2d|me.ObservableVector2d} [v=me.Body.getBounds().center] an optional point to rotate around
648
- * @return {me.Body} Reference to this object for method chaining
642
+ * @returns {me.Body} Reference to this object for method chaining
649
643
  */
650
644
  rotate(angle, v = this.getBounds().center) {
651
645
  this.bounds.clear();
@@ -670,8 +664,8 @@ class Body {
670
664
  * @name setMaxVelocity
671
665
  * @memberOf me.Body
672
666
  * @function
673
- * @param {Number} x max velocity on x axis
674
- * @param {Number} y max velocity on y axis
667
+ * @param {number} x max velocity on x axis
668
+ * @param {number} y max velocity on y axis
675
669
  * @protected
676
670
  */
677
671
  setMaxVelocity(x, y) {
@@ -684,8 +678,8 @@ class Body {
684
678
  * @name setFriction
685
679
  * @memberOf me.Body
686
680
  * @function
687
- * @param {Number} x horizontal friction
688
- * @param {Number} y vertical friction
681
+ * @param {number} x horizontal friction
682
+ * @param {number} y vertical friction
689
683
  * @protected
690
684
  */
691
685
  setFriction(x = 0, y = 0) {
@@ -771,8 +765,8 @@ class Body {
771
765
  * @ignore
772
766
  * @memberOf me.Body
773
767
  * @function
774
- * @return {boolean} true if resulting velocity is different than 0
775
- * @see source code for me.Body.computeVelocity (private member)
768
+ * @param {number} dt time since the last update in milliseconds.
769
+ * @returns {boolean} true if resulting velocity is different than 0
776
770
  */
777
771
  update(dt) {
778
772
  // update the velocity
@@ -9,7 +9,7 @@ import Polygon from "./../shapes/poly.js";
9
9
  * @constructor
10
10
  * @memberOf me
11
11
  * @param {me.Vector2d[]} [vertices] an array of me.Vector2d points
12
- * @return {me.Bounds} A new bounds object
12
+ * @returns {me.Bounds} A new bounds object
13
13
  */
14
14
 
15
15
  class Bounds {
@@ -49,10 +49,10 @@ class Bounds {
49
49
  * @name setMinMax
50
50
  * @memberOf me.Bounds
51
51
  * @function
52
- * @param {Number} minX
53
- * @param {Number} minY
54
- * @param {Number} maxX
55
- * @param {Number} maxY
52
+ * @param {number} minX
53
+ * @param {number} minY
54
+ * @param {number} maxX
55
+ * @param {number} maxY
56
56
  */
57
57
  setMinMax(minX, minY, maxX, maxY) {
58
58
  this.min.x = minX;
@@ -65,7 +65,7 @@ class Bounds {
65
65
  /**
66
66
  * x position of the bound
67
67
  * @public
68
- * @type {Number}
68
+ * @type {number}
69
69
  * @name x
70
70
  * @memberOf me.Bounds
71
71
  */
@@ -82,7 +82,7 @@ class Bounds {
82
82
  /**
83
83
  * y position of the bounds
84
84
  * @public
85
- * @type {Number}
85
+ * @type {number}
86
86
  * @name y
87
87
  * @memberOf me.Bounds
88
88
  */
@@ -100,7 +100,7 @@ class Bounds {
100
100
  /**
101
101
  * width of the bounds
102
102
  * @public
103
- * @type {Number}
103
+ * @type {number}
104
104
  * @name width
105
105
  * @memberOf me.Bounds
106
106
  */
@@ -115,7 +115,7 @@ class Bounds {
115
115
  /**
116
116
  * width of the bounds
117
117
  * @public
118
- * @type {Number}
118
+ * @type {number}
119
119
  * @name width
120
120
  * @memberOf me.Bounds
121
121
  */
@@ -130,7 +130,7 @@ class Bounds {
130
130
  /**
131
131
  * left coordinate of the bound
132
132
  * @public
133
- * @type {Number}
133
+ * @type {number}
134
134
  * @name left
135
135
  * @memberOf me.Bounds
136
136
  */
@@ -141,7 +141,7 @@ class Bounds {
141
141
  /**
142
142
  * right coordinate of the bound
143
143
  * @public
144
- * @type {Number}
144
+ * @type {number}
145
145
  * @name right
146
146
  * @memberOf me.Bounds
147
147
  */
@@ -152,7 +152,7 @@ class Bounds {
152
152
  /**
153
153
  * top coordinate of the bound
154
154
  * @public
155
- * @type {Number}
155
+ * @type {number}
156
156
  * @name top
157
157
  * @memberOf me.Bounds
158
158
  */
@@ -163,7 +163,7 @@ class Bounds {
163
163
  /**
164
164
  * bottom coordinate of the bound
165
165
  * @public
166
- * @type {Number}
166
+ * @type {number}
167
167
  * @name bottom
168
168
  * @memberOf me.Bounds
169
169
  */
@@ -174,7 +174,7 @@ class Bounds {
174
174
  /**
175
175
  * center position of the bound on the x axis
176
176
  * @public
177
- * @type {Number}
177
+ * @type {number}
178
178
  * @name centerX
179
179
  * @memberOf me.Bounds
180
180
  */
@@ -185,7 +185,7 @@ class Bounds {
185
185
  /**
186
186
  * center position of the bound on the y axis
187
187
  * @public
188
- * @type {Number}
188
+ * @type {number}
189
189
  * @name centerY
190
190
  * @memberOf me.Bounds
191
191
  */
@@ -260,8 +260,8 @@ class Bounds {
260
260
  * @name addPoint
261
261
  * @memberOf me.Bounds
262
262
  * @function
263
- * @param {me.Vector2d} vector
264
- * @param {me.Matrix2d} [matrix] an optional transform to apply to the given point
263
+ * @param {me.Vector2d} v
264
+ * @param {me.Matrix2d} [m] an optional transform to apply to the given point
265
265
  */
266
266
  addPoint(v, m) {
267
267
  if (typeof m !== "undefined") {
@@ -278,11 +278,11 @@ class Bounds {
278
278
  * @name addFrame
279
279
  * @memberOf me.Bounds
280
280
  * @function
281
- * @param {Number} x0 - left X coordinates of the quad
282
- * @param {Number} y0 - top Y coordinates of the quad
283
- * @param {Number} x1 - right X coordinates of the quad
284
- * @param {Number} y1 - bottom y coordinates of the quad
285
- * @param {me.Matrix2d} [matrix] an optional transform to apply to the given frame coordinates
281
+ * @param {number} x0 - left X coordinates of the quad
282
+ * @param {number} y0 - top Y coordinates of the quad
283
+ * @param {number} x1 - right X coordinates of the quad
284
+ * @param {number} y1 - bottom y coordinates of the quad
285
+ * @param {me.Matrix2d} [m] an optional transform to apply to the given frame coordinates
286
286
  */
287
287
  addFrame(x0, y0, x1, y1, m) {
288
288
  var v = me.pool.pull("Vector2d");
@@ -302,16 +302,16 @@ class Bounds {
302
302
  * @memberOf me.Bounds
303
303
  * @function
304
304
  * @param {me.Vector2d} point
305
- * @return {boolean} True if the bounds contain the point, otherwise false
305
+ * @returns {boolean} True if the bounds contain the point, otherwise false
306
306
  */
307
307
  /**
308
308
  * Returns true if the bounds contains the given point.
309
309
  * @name contains
310
310
  * @memberOf me.Bounds
311
311
  * @function
312
- * @param {Number} x
313
- * @param {Number} y
314
- * @return {boolean} True if the bounds contain the point, otherwise false
312
+ * @param {number} x
313
+ * @param {number} y
314
+ * @returns {boolean} True if the bounds contain the point, otherwise false
315
315
  */
316
316
  contains() {
317
317
  var arg0 = arguments[0];
@@ -344,11 +344,11 @@ class Bounds {
344
344
  * @memberOf me.Bounds
345
345
  * @function
346
346
  * @param {me.Bounds|me.Rect} bounds
347
- * @return {boolean} True if the bounds overlap, otherwise false
347
+ * @returns {boolean} True if the bounds overlap, otherwise false
348
348
  */
349
349
  overlaps(bounds) {
350
- return (this.left <= bounds.right && this.right >= bounds.left
351
- && this.bottom >= bounds.top && this.top <= bounds.bottom);
350
+ return !(this.right < bounds.left || this.left > bounds.right ||
351
+ this.bottom < bounds.top || this.top > bounds.bottom);
352
352
  }
353
353
 
354
354
  /**
@@ -356,7 +356,7 @@ class Bounds {
356
356
  * @name isFinite
357
357
  * @memberOf me.Bounds
358
358
  * @function
359
- * @return {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
359
+ * @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
360
360
  */
361
361
  isFinite() {
362
362
  return (isFinite(this.min.x) && isFinite(this.max.x) && isFinite(this.min.y) && isFinite(this.max.y));
@@ -374,8 +374,8 @@ class Bounds {
374
374
  * @name translate
375
375
  * @memberOf me.Bounds
376
376
  * @function
377
- * @param {Number} x
378
- * @param {Number} y
377
+ * @param {number} x
378
+ * @param {number} y
379
379
  */
380
380
  translate() {
381
381
  var _x, _y;
@@ -406,8 +406,8 @@ class Bounds {
406
406
  * @name shift
407
407
  * @memberOf me.Bounds
408
408
  * @function
409
- * @param {Number} x
410
- * @param {Number} y
409
+ * @param {number} x
410
+ * @param {number} y
411
411
  */
412
412
  shift() {
413
413
  var _x, _y;
@@ -436,7 +436,7 @@ class Bounds {
436
436
  * @name clone
437
437
  * @memberOf me.Bounds
438
438
  * @function
439
- * @return {me.Bounds}
439
+ * @returns {me.Bounds}
440
440
  */
441
441
  clone() {
442
442
  var bounds = new Bounds();
@@ -449,7 +449,7 @@ class Bounds {
449
449
  * @name toPolygon
450
450
  * @memberOf me.Bounds
451
451
  * @function
452
- * @return {me.Polygon} a new Polygon that represents this bounds.
452
+ * @returns {me.Polygon} a new Polygon that represents this bounds.
453
453
  */
454
454
  toPolygon () {
455
455
  return new Polygon(this.x, this.y, [
@@ -14,7 +14,7 @@ var collision = {
14
14
  * @name maxChildren
15
15
  * @memberOf me.collision
16
16
  * @public
17
- * @type {Number}
17
+ * @type {number}
18
18
  * @default 8
19
19
  * @see me.game.world.broadphase
20
20
  */
@@ -25,27 +25,26 @@ var collision = {
25
25
  * @name maxDepth
26
26
  * @memberOf me.collision
27
27
  * @public
28
- * @type {Number}
28
+ * @type {number}
29
29
  * @default 4
30
30
  * @see me.game.world.broadphase
31
- *
32
31
  */
33
32
  maxDepth : 4,
34
33
 
35
34
  /**
36
35
  * Enum for collision type values.
37
- * @property NO_OBJECT to disable collision check
38
- * @property PLAYER_OBJECT
39
- * @property NPC_OBJECT
40
- * @property ENEMY_OBJECT
41
- * @property COLLECTABLE_OBJECT
42
- * @property ACTION_OBJECT e.g. doors
43
- * @property PROJECTILE_OBJECT e.g. missiles
44
- * @property WORLD_SHAPE e.g. walls; for map collision shapes
45
- * @property USER user-defined collision types (see example)
46
- * @property ALL_OBJECT all of the above (including user-defined types)
36
+ * @property {number} NO_OBJECT to disable collision check
37
+ * @property {number} PLAYER_OBJECT playbable characters
38
+ * @property {number} NPC_OBJECT non playable characters
39
+ * @property {number} ENEMY_OBJECT enemies objects
40
+ * @property {number} COLLECTABLE_OBJECT collectable objects
41
+ * @property {number} ACTION_OBJECT e.g. doors
42
+ * @property {number} PROJECTILE_OBJECT e.g. missiles
43
+ * @property {number} WORLD_SHAPE e.g. walls; for map collision shapes
44
+ * @property {number} USER user-defined collision types (see example)
45
+ * @property {number} ALL_OBJECT all of the above (including user-defined types)
47
46
  * @readonly
48
- * @enum {Number}
47
+ * @enum {number}
49
48
  * @name types
50
49
  * @memberOf me.collision
51
50
  * @see me.body.setCollisionMask
@@ -112,7 +111,7 @@ var collision = {
112
111
  * @function
113
112
  * @param {me.Line} line line to be tested for collision
114
113
  * @param {Array.<me.Renderable>} [result] a user defined array that will be populated with intersecting physic objects.
115
- * @return {Array.<me.Renderable>} an array of intersecting physic objects
114
+ * @returns {Array.<me.Renderable>} an array of intersecting physic objects
116
115
  * @example
117
116
  * // define a line accross the viewport
118
117
  * var ray = new me.Line(
@@ -131,7 +130,7 @@ var collision = {
131
130
  * // ...
132
131
  * }
133
132
  */
134
- rayCast(line, resultArray) { return rayCast(line, resultArray); }
133
+ rayCast(line, result) { return rayCast(line, result); }
135
134
  };
136
135
 
137
136
  export default collision;
@@ -22,7 +22,7 @@ var dummyObj = {
22
22
  * @function
23
23
  * @param {me.Renderable} a a reference to the object A.
24
24
  * @param {me.Renderable} b a reference to the object B.
25
- * @return {Boolean} true if they should collide, false otherwise
25
+ * @returns {boolean} true if they should collide, false otherwise
26
26
  */
27
27
  function shouldCollide(a, b) {
28
28
  return (
@@ -38,17 +38,16 @@ function shouldCollide(a, b) {
38
38
  * An object representing the result of an intersection.
39
39
  * @property {me.Renderable} a The first object participating in the intersection
40
40
  * @property {me.Renderable} b The second object participating in the intersection
41
- * @property {Number} overlap Magnitude of the overlap on the shortest colliding axis
41
+ * @property {number} overlap Magnitude of the overlap on the shortest colliding axis
42
42
  * @property {me.Vector2d} overlapV The overlap vector (i.e. `overlapN.scale(overlap, overlap)`). If this vector is subtracted from the position of a, a and b will no longer be colliding
43
43
  * @property {me.Vector2d} overlapN The shortest colliding axis (unit-vector)
44
- * @property {Boolean} aInB Whether the first object is entirely inside the second
45
- * @property {Boolean} bInA Whether the second object is entirely inside the first
46
- * @property {Number} indexShapeA The index of the colliding shape for the object a body
47
- * @property {Number} indexShapeB The index of the colliding shape for the object b body
44
+ * @property {boolean} aInB Whether the first object is entirely inside the second
45
+ * @property {boolean} bInA Whether the second object is entirely inside the first
46
+ * @property {number} indexShapeA The index of the colliding shape for the object a body
47
+ * @property {number} indexShapeB The index of the colliding shape for the object b body
48
48
  * @name ResponseObject
49
49
  * @memberOf me.collision
50
50
  * @public
51
- * @see me.collision.check
52
51
  */
53
52
  class ResponseObject {
54
53
  constructor() {
@@ -61,7 +60,6 @@ class ResponseObject {
61
60
  this.indexShapeA = -1;
62
61
  this.indexShapeB = -1;
63
62
  this.overlap = Number.MAX_VALUE;
64
- return this;
65
63
  }
66
64
 
67
65
  /**
@@ -73,6 +71,7 @@ class ResponseObject {
73
71
  * @memberOf me.collision.ResponseObject
74
72
  * @public
75
73
  * @function
74
+ * @returns {object} this object for chaining
76
75
  */
77
76
  clear () {
78
77
  this.aInB = true;
@@ -92,9 +91,9 @@ export var globalResponse = new ResponseObject();
92
91
  * @name collisionCheck
93
92
  * @ignore
94
93
  * @function
95
- * @param {me.Renderable} obj object to be tested for collision
94
+ * @param {me.Renderable} objA object to be tested for collision
96
95
  * @param {me.collision.ResponseObject} [response=me.collision.response] a user defined response object that will be populated if they intersect.
97
- * @return {Boolean} in case of collision, false otherwise
96
+ * @returns {boolean} in case of collision, false otherwise
98
97
  */
99
98
  export function collisionCheck(objA, response = globalResponse) {
100
99
  var collisionCounter = 0;
@@ -166,7 +165,7 @@ export function collisionCheck(objA, response = globalResponse) {
166
165
  * @function
167
166
  * @param {me.Line} line line to be tested for collision
168
167
  * @param {Array.<me.Renderable>} [result] a user defined array that will be populated with intersecting physic objects.
169
- * @return {Array.<me.Renderable>} an array of intersecting physic objects
168
+ * @returns {Array.<me.Renderable>} an array of intersecting physic objects
170
169
  * @example
171
170
  * // define a line accross the viewport
172
171
  * var ray = new me.Line(