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
@@ -1,15 +1,13 @@
1
1
  import Vector2d from "./../math/vector2.js";
2
- import Polygon from "./../shapes/poly.js";
2
+ import Polygon from "./../geometries/poly.js";
3
3
 
4
4
  /**
5
5
  * @classdesc
6
6
  * a bound object contains methods for creating and manipulating axis-aligned bounding boxes (AABB).
7
7
  * @class Bounds
8
- * @memberOf me
9
- * @constructor
10
- * @memberOf me
8
+ * @memberof me
11
9
  * @param {me.Vector2d[]} [vertices] an array of me.Vector2d points
12
- * @return {me.Bounds} A new bounds object
10
+ * @returns {me.Bounds} A new bounds object
13
11
  */
14
12
 
15
13
  class Bounds {
@@ -36,7 +34,7 @@ class Bounds {
36
34
  /**
37
35
  * reset the bound
38
36
  * @name clear
39
- * @memberOf me.Bounds
37
+ * @memberof me.Bounds
40
38
  * @function
41
39
  */
42
40
  clear() {
@@ -47,12 +45,12 @@ class Bounds {
47
45
  /**
48
46
  * sets the bounds to the given min and max value
49
47
  * @name setMinMax
50
- * @memberOf me.Bounds
48
+ * @memberof me.Bounds
51
49
  * @function
52
- * @param {Number} minX
53
- * @param {Number} minY
54
- * @param {Number} maxX
55
- * @param {Number} maxY
50
+ * @param {number} minX
51
+ * @param {number} minY
52
+ * @param {number} maxX
53
+ * @param {number} maxY
56
54
  */
57
55
  setMinMax(minX, minY, maxX, maxY) {
58
56
  this.min.x = minX;
@@ -65,9 +63,9 @@ class Bounds {
65
63
  /**
66
64
  * x position of the bound
67
65
  * @public
68
- * @type {Number}
66
+ * @type {number}
69
67
  * @name x
70
- * @memberOf me.Bounds
68
+ * @memberof me.Bounds
71
69
  */
72
70
  get x() {
73
71
  return this.min.x;
@@ -82,9 +80,9 @@ class Bounds {
82
80
  /**
83
81
  * y position of the bounds
84
82
  * @public
85
- * @type {Number}
83
+ * @type {number}
86
84
  * @name y
87
- * @memberOf me.Bounds
85
+ * @memberof me.Bounds
88
86
  */
89
87
  get y() {
90
88
  return this.min.y;
@@ -100,9 +98,9 @@ class Bounds {
100
98
  /**
101
99
  * width of the bounds
102
100
  * @public
103
- * @type {Number}
101
+ * @type {number}
104
102
  * @name width
105
- * @memberOf me.Bounds
103
+ * @memberof me.Bounds
106
104
  */
107
105
  get width() {
108
106
  return this.max.x - this.min.x;
@@ -115,9 +113,9 @@ class Bounds {
115
113
  /**
116
114
  * width of the bounds
117
115
  * @public
118
- * @type {Number}
116
+ * @type {number}
119
117
  * @name width
120
- * @memberOf me.Bounds
118
+ * @memberof me.Bounds
121
119
  */
122
120
  get height() {
123
121
  return this.max.y - this.min.y;
@@ -130,9 +128,9 @@ class Bounds {
130
128
  /**
131
129
  * left coordinate of the bound
132
130
  * @public
133
- * @type {Number}
131
+ * @type {number}
134
132
  * @name left
135
- * @memberOf me.Bounds
133
+ * @memberof me.Bounds
136
134
  */
137
135
  get left() {
138
136
  return this.min.x;
@@ -141,9 +139,9 @@ class Bounds {
141
139
  /**
142
140
  * right coordinate of the bound
143
141
  * @public
144
- * @type {Number}
142
+ * @type {number}
145
143
  * @name right
146
- * @memberOf me.Bounds
144
+ * @memberof me.Bounds
147
145
  */
148
146
  get right() {
149
147
  return this.max.x;
@@ -152,9 +150,9 @@ class Bounds {
152
150
  /**
153
151
  * top coordinate of the bound
154
152
  * @public
155
- * @type {Number}
153
+ * @type {number}
156
154
  * @name top
157
- * @memberOf me.Bounds
155
+ * @memberof me.Bounds
158
156
  */
159
157
  get top() {
160
158
  return this.min.y;
@@ -163,9 +161,9 @@ class Bounds {
163
161
  /**
164
162
  * bottom coordinate of the bound
165
163
  * @public
166
- * @type {Number}
164
+ * @type {number}
167
165
  * @name bottom
168
- * @memberOf me.Bounds
166
+ * @memberof me.Bounds
169
167
  */
170
168
  get bottom() {
171
169
  return this.max.y;
@@ -174,9 +172,9 @@ class Bounds {
174
172
  /**
175
173
  * center position of the bound on the x axis
176
174
  * @public
177
- * @type {Number}
175
+ * @type {number}
178
176
  * @name centerX
179
- * @memberOf me.Bounds
177
+ * @memberof me.Bounds
180
178
  */
181
179
  get centerX() {
182
180
  return this.min.x + (this.width / 2);
@@ -185,9 +183,9 @@ class Bounds {
185
183
  /**
186
184
  * center position of the bound on the y axis
187
185
  * @public
188
- * @type {Number}
186
+ * @type {number}
189
187
  * @name centerY
190
- * @memberOf me.Bounds
188
+ * @memberof me.Bounds
191
189
  */
192
190
  get centerY() {
193
191
  return this.min.y + (this.height / 2);
@@ -198,7 +196,7 @@ class Bounds {
198
196
  * @public
199
197
  * @type {me.Vector2d}
200
198
  * @name center
201
- * @memberOf me.Bounds
199
+ * @memberof me.Bounds
202
200
  */
203
201
  get center() {
204
202
  return this._center.set(this.centerX, this.centerY);
@@ -207,7 +205,7 @@ class Bounds {
207
205
  /**
208
206
  * Updates bounds using the given vertices
209
207
  * @name update
210
- * @memberOf me.Bounds
208
+ * @memberof me.Bounds
211
209
  * @function
212
210
  * @param {me.Vector2d[]} vertices an array of me.Vector2d points
213
211
  */
@@ -218,7 +216,7 @@ class Bounds {
218
216
  /**
219
217
  * add the given vertices to the bounds definition.
220
218
  * @name add
221
- * @memberOf me.Bounds
219
+ * @memberof me.Bounds
222
220
  * @function
223
221
  * @param {me.Vector2d[]} vertices an array of me.Vector2d points
224
222
  * @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
@@ -239,7 +237,7 @@ class Bounds {
239
237
  /**
240
238
  * add the given bounds to the bounds definition.
241
239
  * @name addBounds
242
- * @memberOf me.Bounds
240
+ * @memberof me.Bounds
243
241
  * @function
244
242
  * @param {me.Bounds} bounds
245
243
  * @param {boolean} [clear=false] either to reset the bounds before adding the new vertices
@@ -258,10 +256,10 @@ class Bounds {
258
256
  /**
259
257
  * add the given point to the bounds definition.
260
258
  * @name addPoint
261
- * @memberOf me.Bounds
259
+ * @memberof me.Bounds
262
260
  * @function
263
- * @param {me.Vector2d} vector
264
- * @param {me.Matrix2d} [matrix] an optional transform to apply to the given point
261
+ * @param {me.Vector2d} v
262
+ * @param {me.Matrix2d} [m] an optional transform to apply to the given point
265
263
  */
266
264
  addPoint(v, m) {
267
265
  if (typeof m !== "undefined") {
@@ -276,13 +274,13 @@ class Bounds {
276
274
  /**
277
275
  * add the given quad coordinates to this bound definition, multiplied by the given matrix
278
276
  * @name addFrame
279
- * @memberOf me.Bounds
277
+ * @memberof me.Bounds
280
278
  * @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
279
+ * @param {number} x0 - left X coordinates of the quad
280
+ * @param {number} y0 - top Y coordinates of the quad
281
+ * @param {number} x1 - right X coordinates of the quad
282
+ * @param {number} y1 - bottom y coordinates of the quad
283
+ * @param {me.Matrix2d} [m] an optional transform to apply to the given frame coordinates
286
284
  */
287
285
  addFrame(x0, y0, x1, y1, m) {
288
286
  var v = me.pool.pull("Vector2d");
@@ -299,19 +297,19 @@ class Bounds {
299
297
  /**
300
298
  * Returns true if the bounds contains the given point.
301
299
  * @name contains
302
- * @memberOf me.Bounds
300
+ * @memberof me.Bounds
303
301
  * @function
304
302
  * @param {me.Vector2d} point
305
- * @return {boolean} True if the bounds contain the point, otherwise false
303
+ * @returns {boolean} True if the bounds contain the point, otherwise false
306
304
  */
307
305
  /**
308
306
  * Returns true if the bounds contains the given point.
309
307
  * @name contains
310
- * @memberOf me.Bounds
308
+ * @memberof me.Bounds
311
309
  * @function
312
- * @param {Number} x
313
- * @param {Number} y
314
- * @return {boolean} True if the bounds contain the point, otherwise false
310
+ * @param {number} x
311
+ * @param {number} y
312
+ * @returns {boolean} True if the bounds contain the point, otherwise false
315
313
  */
316
314
  contains() {
317
315
  var arg0 = arguments[0];
@@ -341,10 +339,10 @@ class Bounds {
341
339
  /**
342
340
  * Returns true if the two bounds intersect.
343
341
  * @name overlaps
344
- * @memberOf me.Bounds
342
+ * @memberof me.Bounds
345
343
  * @function
346
344
  * @param {me.Bounds|me.Rect} bounds
347
- * @return {boolean} True if the bounds overlap, otherwise false
345
+ * @returns {boolean} True if the bounds overlap, otherwise false
348
346
  */
349
347
  overlaps(bounds) {
350
348
  return !(this.right < bounds.left || this.left > bounds.right ||
@@ -354,9 +352,9 @@ class Bounds {
354
352
  /**
355
353
  * determines whether all coordinates of this bounds are finite numbers.
356
354
  * @name isFinite
357
- * @memberOf me.Bounds
355
+ * @memberof me.Bounds
358
356
  * @function
359
- * @return {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
357
+ * @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
360
358
  */
361
359
  isFinite() {
362
360
  return (isFinite(this.min.x) && isFinite(this.max.x) && isFinite(this.min.y) && isFinite(this.max.y));
@@ -365,17 +363,17 @@ class Bounds {
365
363
  /**
366
364
  * Translates the bounds by the given vector.
367
365
  * @name translate
368
- * @memberOf me.Bounds
366
+ * @memberof me.Bounds
369
367
  * @function
370
368
  * @param {me.Vector2d} vector
371
369
  */
372
370
  /**
373
371
  * Translates the bounds by x on the x axis, and y on the y axis
374
372
  * @name translate
375
- * @memberOf me.Bounds
373
+ * @memberof me.Bounds
376
374
  * @function
377
- * @param {Number} x
378
- * @param {Number} y
375
+ * @param {number} x
376
+ * @param {number} y
379
377
  */
380
378
  translate() {
381
379
  var _x, _y;
@@ -397,17 +395,17 @@ class Bounds {
397
395
  /**
398
396
  * Shifts the bounds to the given position vector.
399
397
  * @name shift
400
- * @memberOf me.Bounds
398
+ * @memberof me.Bounds
401
399
  * @function
402
400
  * @param {me.Vector2d} position
403
401
  */
404
402
  /**
405
403
  * Shifts the bounds to the given x, y position.
406
404
  * @name shift
407
- * @memberOf me.Bounds
405
+ * @memberof me.Bounds
408
406
  * @function
409
- * @param {Number} x
410
- * @param {Number} y
407
+ * @param {number} x
408
+ * @param {number} y
411
409
  */
412
410
  shift() {
413
411
  var _x, _y;
@@ -434,9 +432,9 @@ class Bounds {
434
432
  /**
435
433
  * clone this bounds
436
434
  * @name clone
437
- * @memberOf me.Bounds
435
+ * @memberof me.Bounds
438
436
  * @function
439
- * @return {me.Bounds}
437
+ * @returns {me.Bounds}
440
438
  */
441
439
  clone() {
442
440
  var bounds = new Bounds();
@@ -447,9 +445,9 @@ class Bounds {
447
445
  /**
448
446
  * Returns a polygon whose edges are the same as this bounds.
449
447
  * @name toPolygon
450
- * @memberOf me.Bounds
448
+ * @memberof me.Bounds
451
449
  * @function
452
- * @return {me.Polygon} a new Polygon that represents this bounds.
450
+ * @returns {me.Polygon} a new Polygon that represents this bounds.
453
451
  */
454
452
  toPolygon () {
455
453
  return new Polygon(this.x, this.y, [
@@ -4,7 +4,7 @@ import { rayCast, globalResponse } from "./detector.js";
4
4
  * Collision detection (and projection-based collision response) of 2D shapes.<br>
5
5
  * Based on the Separating Axis Theorem and supports detecting collisions between simple Axis-Aligned Boxes, convex polygons and circles based shapes.
6
6
  * @namespace collision
7
- * @memberOf me
7
+ * @memberof me
8
8
  */
9
9
 
10
10
  var collision = {
@@ -12,9 +12,9 @@ var collision = {
12
12
  /**
13
13
  * The maximum number of children that a quadtree node can contain before it is split into sub-nodes.
14
14
  * @name maxChildren
15
- * @memberOf me.collision
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
  */
@@ -23,31 +23,30 @@ var collision = {
23
23
  /**
24
24
  * The maximum number of levels that the quadtree will create.
25
25
  * @name maxDepth
26
- * @memberOf me.collision
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
- * @memberOf me.collision
49
+ * @memberof me.collision
51
50
  * @see me.body.setCollisionMask
52
51
  * @see me.body.collisionType
53
52
  * @example
@@ -98,7 +97,7 @@ var collision = {
98
97
  * a global instance of a response object used for collision detection <br>
99
98
  * this object will be reused amongst collision detection call if not user-defined response is specified
100
99
  * @name response
101
- * @memberOf me.collision
100
+ * @memberof me.collision
102
101
  * @public
103
102
  * @type {me.collision.ResponseObject}
104
103
  */
@@ -107,12 +106,12 @@ var collision = {
107
106
  /**
108
107
  * Checks for object colliding with the given line
109
108
  * @name rayCast
110
- * @memberOf me.collision
109
+ * @memberof me.collision
111
110
  * @public
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;
@@ -17,12 +17,12 @@ var dummyObj = {
17
17
  * a function used to determine if two objects should collide (based on both respective objects collision mask and type).<br>
18
18
  * you can redefine this function if you need any specific rules over what should collide with what.
19
19
  * @name shouldCollide
20
- * @memberOf me.collision
20
+ * @memberof me.collision
21
21
  * @ignore
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,15 +38,15 @@ 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
- * @memberOf me.collision
49
+ * @memberof me.collision
50
50
  * @public
51
51
  */
52
52
  class ResponseObject {
@@ -60,7 +60,6 @@ class ResponseObject {
60
60
  this.indexShapeA = -1;
61
61
  this.indexShapeB = -1;
62
62
  this.overlap = Number.MAX_VALUE;
63
- return this;
64
63
  }
65
64
 
66
65
  /**
@@ -69,9 +68,10 @@ class ResponseObject {
69
68
  * Response object for multiple intersection tests <br>
70
69
  * (recommended as it will avoid allocating extra memory) <br>
71
70
  * @name clear
72
- * @memberOf me.collision.ResponseObject
71
+ * @memberof me.collision.ResponseObject
73
72
  * @public
74
73
  * @function
74
+ * @returns {object} this object for chaining
75
75
  */
76
76
  clear () {
77
77
  this.aInB = true;
@@ -91,9 +91,9 @@ export var globalResponse = new ResponseObject();
91
91
  * @name collisionCheck
92
92
  * @ignore
93
93
  * @function
94
- * @param {me.Renderable} obj object to be tested for collision
94
+ * @param {me.Renderable} objA object to be tested for collision
95
95
  * @param {me.collision.ResponseObject} [response=me.collision.response] a user defined response object that will be populated if they intersect.
96
- * @return {Boolean} in case of collision, false otherwise
96
+ * @returns {boolean} in case of collision, false otherwise
97
97
  */
98
98
  export function collisionCheck(objA, response = globalResponse) {
99
99
  var collisionCounter = 0;
@@ -165,7 +165,7 @@ export function collisionCheck(objA, response = globalResponse) {
165
165
  * @function
166
166
  * @param {me.Line} line line to be tested for collision
167
167
  * @param {Array.<me.Renderable>} [result] a user defined array that will be populated with intersecting physic objects.
168
- * @return {Array.<me.Renderable>} an array of intersecting physic objects
168
+ * @returns {Array.<me.Renderable>} an array of intersecting physic objects
169
169
  * @example
170
170
  * // define a line accross the viewport
171
171
  * var ray = new me.Line(
@@ -53,13 +53,12 @@ var QT_VECTOR = new Vector2d();
53
53
  * a QuadTree implementation in JavaScript, a 2d spatial subdivision algorithm.
54
54
  * @class
55
55
  * @name QuadTree
56
- * @memberOf me
57
- * @constructor
56
+ * @memberof me
58
57
  * @see me.game.world.broadphase
59
58
  * @param {me.Bounds} bounds bounds of the node
60
- * @param {Number} [max_objects=4] max objects a node can hold before splitting into 4 subnodes
61
- * @param {Number} [max_levels=4] total max levels inside root Quadtree
62
- * @param {Number} [level] deepth level, required for subnodes
59
+ * @param {number} [max_objects=4] max objects a node can hold before splitting into 4 subnodes
60
+ * @param {number} [max_levels=4] total max levels inside root Quadtree
61
+ * @param {number} [level] deepth level, required for subnodes
63
62
  */
64
63
  class QuadTree {
65
64
 
@@ -120,14 +119,15 @@ class QuadTree {
120
119
  /*
121
120
  * Determine which node the object belongs to
122
121
  * @param {me.Rect} rect bounds of the area to be checked
123
- * @return Integer index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node
122
+ * @returns Integer index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node
124
123
  */
125
124
  getIndex(item) {
126
125
  var pos;
126
+ var bounds = item.getBounds();
127
127
 
128
128
  // use game world coordinates for floating items
129
- if (item.floating || (item.ancestor && item.ancestor.floating)) {
130
- pos = viewport.localToWorld(item.left, item.top, QT_VECTOR);
129
+ if (item.isFloating === true) {
130
+ pos = viewport.localToWorld(bounds.left, bounds.top, QT_VECTOR);
131
131
  } else {
132
132
  pos = QT_VECTOR.set(item.left, item.top);
133
133
  }
@@ -135,8 +135,8 @@ class QuadTree {
135
135
  var index = -1,
136
136
  rx = pos.x,
137
137
  ry = pos.y,
138
- rw = item.width,
139
- rh = item.height,
138
+ rw = bounds.width,
139
+ rh = bounds.height,
140
140
  verticalMidpoint = this.bounds.left + (this.bounds.width / 2),
141
141
  horizontalMidpoint = this.bounds.top + (this.bounds.height / 2),
142
142
  //rect can completely fit within the top quadrants
@@ -166,7 +166,7 @@ class QuadTree {
166
166
  /**
167
167
  * Insert the given object container into the node.
168
168
  * @name insertContainer
169
- * @memberOf me.QuadTree
169
+ * @memberof me.QuadTree
170
170
  * @function
171
171
  * @param {me.Container} container group of objects to be added
172
172
  */
@@ -195,9 +195,9 @@ class QuadTree {
195
195
  * exceeds the capacity, it will split and add all
196
196
  * objects to their corresponding subnodes.
197
197
  * @name insert
198
- * @memberOf me.QuadTree
198
+ * @memberof me.QuadTree
199
199
  * @function
200
- * @param {Object} item object to be added
200
+ * @param {object} item object to be added
201
201
  */
202
202
  insert(item) {
203
203
  var index = -1;
@@ -240,11 +240,11 @@ class QuadTree {
240
240
  /**
241
241
  * Return all objects that could collide with the given object
242
242
  * @name retrieve
243
- * @memberOf me.QuadTree
243
+ * @memberof me.QuadTree
244
244
  * @function
245
- * @param {Object} object object to be checked against
246
- * @param {Object} [function] a sorting function for the returned array
247
- * @return {Object[]} array with all detected objects
245
+ * @param {object} item object to be checked against
246
+ * @param {object} [fn] a sorting function for the returned array
247
+ * @returns {object[]} array with all detected objects
248
248
  */
249
249
  retrieve(item, fn) {
250
250
  var returnObjects = this.objects;
@@ -276,10 +276,10 @@ class QuadTree {
276
276
  * Remove the given item from the quadtree.
277
277
  * (this function won't recalculate the impacted node)
278
278
  * @name remove
279
- * @memberOf me.QuadTree
279
+ * @memberof me.QuadTree
280
280
  * @function
281
- * @param {Object} object object to be removed
282
- * @return true if the item was found and removed.
281
+ * @param {object} item object to be removed
282
+ * @returns {boolean} true if the item was found and removed.
283
283
  */
284
284
  remove(item) {
285
285
  var found = false;
@@ -317,9 +317,9 @@ class QuadTree {
317
317
  /**
318
318
  * return true if the node is prunable
319
319
  * @name isPrunable
320
- * @memberOf me.QuadTree
320
+ * @memberof me.QuadTree
321
321
  * @function
322
- * @return true if the node is prunable
322
+ * @returns {boolean} true if the node is prunable
323
323
  */
324
324
  isPrunable() {
325
325
  return !(this.hasChildren() || (this.objects.length > 0));
@@ -328,9 +328,9 @@ class QuadTree {
328
328
  /**
329
329
  * return true if the node has any children
330
330
  * @name hasChildren
331
- * @memberOf me.QuadTree
331
+ * @memberof me.QuadTree
332
332
  * @function
333
- * @return true if the node has any children
333
+ * @returns {boolean} true if the node has any children
334
334
  */
335
335
  hasChildren() {
336
336
  for (var i = 0; i < this.nodes.length; i = i + 1) {
@@ -345,8 +345,9 @@ class QuadTree {
345
345
  /**
346
346
  * clear the quadtree
347
347
  * @name clear
348
- * @memberOf me.QuadTree
348
+ * @memberof me.QuadTree
349
349
  * @function
350
+ * @param {me.Bounds} [bounds=this.bounds] the bounds to be cleared
350
351
  */
351
352
  clear(bounds) {
352
353
  this.objects.length = 0;