melonjs 10.2.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/physics/body.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Vector2d from "./../math/vector2.js";
|
|
2
|
-
import Rect from "./../
|
|
3
|
-
import Ellipse from "./../
|
|
4
|
-
import Polygon from "./../
|
|
2
|
+
import Rect from "./../geometries/rectangle.js";
|
|
3
|
+
import Ellipse from "./../geometries/ellipse.js";
|
|
4
|
+
import Polygon from "./../geometries/poly.js";
|
|
5
5
|
import Bounds from "./bounds.js";
|
|
6
6
|
import collision from "./collision.js";
|
|
7
7
|
import * as arrayUtil from "./../utils/array.js";
|
|
@@ -13,10 +13,9 @@ import { world } from "./../game.js";
|
|
|
13
13
|
/**
|
|
14
14
|
* a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
|
|
15
15
|
* @class Body
|
|
16
|
-
* @
|
|
17
|
-
* @constructor
|
|
16
|
+
* @memberof me
|
|
18
17
|
* @param {me.Renderable} ancestor the parent object this body is attached to
|
|
19
|
-
* @param {me.Rect|me.Rect[]|me.Polygon|me.Polygon[]|me.Line|me.Line[]|me.Ellipse|me.Ellipse[]|me.Bounds|me.Bounds[]|
|
|
18
|
+
* @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
|
|
20
19
|
* @param {Function} [onBodyUpdate] callback for when the body is updated (e.g. add/remove shapes)
|
|
21
20
|
*/
|
|
22
21
|
class Body {
|
|
@@ -27,7 +26,7 @@ class Body {
|
|
|
27
26
|
* a reference to the parent object that contains this body,
|
|
28
27
|
* or undefined if it has not been added to one.
|
|
29
28
|
* @public
|
|
30
|
-
* @type me.Renderable
|
|
29
|
+
* @type {me.Renderable}
|
|
31
30
|
* @default undefined
|
|
32
31
|
* @name me.Body#ancestor
|
|
33
32
|
*/
|
|
@@ -38,7 +37,7 @@ class Body {
|
|
|
38
37
|
* @public
|
|
39
38
|
* @type {me.Bounds}
|
|
40
39
|
* @name bounds
|
|
41
|
-
* @
|
|
40
|
+
* @memberof me.Body
|
|
42
41
|
*/
|
|
43
42
|
if (typeof this.bounds === "undefined") {
|
|
44
43
|
this.bounds = new Bounds();
|
|
@@ -49,7 +48,7 @@ class Body {
|
|
|
49
48
|
* @ignore
|
|
50
49
|
* @type {me.Polygon[]|me.Line[]|me.Ellipse[]}
|
|
51
50
|
* @name shapes
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.Body
|
|
53
52
|
*/
|
|
54
53
|
if (typeof this.shapes === "undefined") {
|
|
55
54
|
this.shapes = [];
|
|
@@ -59,22 +58,22 @@ class Body {
|
|
|
59
58
|
* The body collision mask, that defines what should collide with what.<br>
|
|
60
59
|
* (by default will collide with all entities)
|
|
61
60
|
* @ignore
|
|
62
|
-
* @type
|
|
61
|
+
* @type {number}
|
|
63
62
|
* @default me.collision.types.ALL_OBJECT
|
|
64
63
|
* @name collisionMask
|
|
65
64
|
* @see me.collision.types
|
|
66
|
-
* @
|
|
65
|
+
* @memberof me.Body
|
|
67
66
|
*/
|
|
68
67
|
this.collisionMask = collision.types.ALL_OBJECT;
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
70
|
* define the collision type of the body for collision filtering
|
|
72
71
|
* @public
|
|
73
|
-
* @type
|
|
72
|
+
* @type {number}
|
|
74
73
|
* @default me.collision.types.ENEMY_OBJECT
|
|
75
74
|
* @name collisionType
|
|
76
75
|
* @see me.collision.types
|
|
77
|
-
* @
|
|
76
|
+
* @memberof me.Body
|
|
78
77
|
* @example
|
|
79
78
|
* // set the body collision type
|
|
80
79
|
* myEntity.body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
@@ -84,10 +83,10 @@ class Body {
|
|
|
84
83
|
/**
|
|
85
84
|
* body velocity
|
|
86
85
|
* @public
|
|
87
|
-
* @type me.Vector2d
|
|
86
|
+
* @type {me.Vector2d}
|
|
88
87
|
* @default <0,0>
|
|
89
88
|
* @name vel
|
|
90
|
-
* @
|
|
89
|
+
* @memberof me.Body
|
|
91
90
|
*/
|
|
92
91
|
if (typeof this.vel === "undefined") {
|
|
93
92
|
this.vel = new Vector2d();
|
|
@@ -98,11 +97,11 @@ class Body {
|
|
|
98
97
|
* body force or acceleration (automatically) applied to the body.
|
|
99
98
|
* when defining a force, user should also define a max velocity
|
|
100
99
|
* @public
|
|
101
|
-
* @type me.Vector2d
|
|
100
|
+
* @type {me.Vector2d}
|
|
102
101
|
* @default <0,0>
|
|
103
102
|
* @name force
|
|
104
103
|
* @see me.Body.setMaxVelocity
|
|
105
|
-
* @
|
|
104
|
+
* @memberof me.Body
|
|
106
105
|
* @example
|
|
107
106
|
* // define a default maximum acceleration, initial force and friction
|
|
108
107
|
* this.body.force.set(0, 0);
|
|
@@ -129,10 +128,10 @@ class Body {
|
|
|
129
128
|
/**
|
|
130
129
|
* body friction
|
|
131
130
|
* @public
|
|
132
|
-
* @type me.Vector2d
|
|
131
|
+
* @type {me.Vector2d}
|
|
133
132
|
* @default <0,0>
|
|
134
133
|
* @name friction
|
|
135
|
-
* @
|
|
134
|
+
* @memberof me.Body
|
|
136
135
|
*/
|
|
137
136
|
if (typeof this.friction === "undefined") {
|
|
138
137
|
this.friction = new Vector2d();
|
|
@@ -143,30 +142,30 @@ class Body {
|
|
|
143
142
|
* the body bouciness level when colliding with other solid bodies :
|
|
144
143
|
* a value of 0 will not bounce, a value of 1 will fully rebound.
|
|
145
144
|
* @public
|
|
146
|
-
* @type {
|
|
145
|
+
* @type {number}
|
|
147
146
|
* @default 0
|
|
148
147
|
* @name bounce
|
|
149
|
-
* @
|
|
148
|
+
* @memberof me.Body
|
|
150
149
|
*/
|
|
151
150
|
this.bounce = 0;
|
|
152
151
|
|
|
153
152
|
/**
|
|
154
153
|
* the body mass
|
|
155
154
|
* @public
|
|
156
|
-
* @type {
|
|
155
|
+
* @type {number}
|
|
157
156
|
* @default 1
|
|
158
157
|
* @name mass
|
|
159
|
-
* @
|
|
158
|
+
* @memberof me.Body
|
|
160
159
|
*/
|
|
161
160
|
this.mass = 1;
|
|
162
161
|
|
|
163
162
|
/**
|
|
164
163
|
* max velocity (to limit body velocity)
|
|
165
164
|
* @public
|
|
166
|
-
* @type me.Vector2d
|
|
165
|
+
* @type {me.Vector2d}
|
|
167
166
|
* @default <490,490>
|
|
168
167
|
* @name maxVel
|
|
169
|
-
* @
|
|
168
|
+
* @memberof me.Body
|
|
170
169
|
*/
|
|
171
170
|
if (typeof this.maxVel === "undefined") {
|
|
172
171
|
this.maxVel = new Vector2d();
|
|
@@ -179,10 +178,10 @@ class Body {
|
|
|
179
178
|
* either this body is a static body or not
|
|
180
179
|
* @readonly
|
|
181
180
|
* @public
|
|
182
|
-
* @type
|
|
181
|
+
* @type {boolean}
|
|
183
182
|
* @default false
|
|
184
183
|
* @name isStatic
|
|
185
|
-
* @
|
|
184
|
+
* @memberof me.Body
|
|
186
185
|
*/
|
|
187
186
|
this.isStatic = false;
|
|
188
187
|
|
|
@@ -191,10 +190,10 @@ class Body {
|
|
|
191
190
|
* The degree to which this body is affected by the world gravity
|
|
192
191
|
* @public
|
|
193
192
|
* @see me.World.gravity
|
|
194
|
-
* @type
|
|
193
|
+
* @type {number}
|
|
195
194
|
* @default 1.0
|
|
196
195
|
* @name gravityScale
|
|
197
|
-
* @
|
|
196
|
+
* @memberof me.Body
|
|
198
197
|
*/
|
|
199
198
|
this.gravityScale = 1.0;
|
|
200
199
|
|
|
@@ -202,10 +201,10 @@ class Body {
|
|
|
202
201
|
* If true this body won't be affected by the world gravity
|
|
203
202
|
* @public
|
|
204
203
|
* @see me.World.gravity
|
|
205
|
-
* @type
|
|
204
|
+
* @type {boolean}
|
|
206
205
|
* @default false
|
|
207
206
|
* @name ignoreGravity
|
|
208
|
-
* @
|
|
207
|
+
* @memberof me.Body
|
|
209
208
|
*/
|
|
210
209
|
this.ignoreGravity = false;
|
|
211
210
|
|
|
@@ -215,10 +214,10 @@ class Body {
|
|
|
215
214
|
* false if the object is standing on something<br>
|
|
216
215
|
* @readonly
|
|
217
216
|
* @public
|
|
218
|
-
* @type
|
|
217
|
+
* @type {boolean}
|
|
219
218
|
* @default false
|
|
220
219
|
* @name falling
|
|
221
|
-
* @
|
|
220
|
+
* @memberof me.Body
|
|
222
221
|
*/
|
|
223
222
|
this.falling = false;
|
|
224
223
|
|
|
@@ -227,10 +226,10 @@ class Body {
|
|
|
227
226
|
* equal true if the body is jumping<br>
|
|
228
227
|
* @readonly
|
|
229
228
|
* @public
|
|
230
|
-
* @type
|
|
229
|
+
* @type {boolean}
|
|
231
230
|
* @default false
|
|
232
231
|
* @name jumping
|
|
233
|
-
* @
|
|
232
|
+
* @memberof me.Body
|
|
234
233
|
*/
|
|
235
234
|
this.jumping = false;
|
|
236
235
|
|
|
@@ -260,10 +259,10 @@ class Body {
|
|
|
260
259
|
* set the body as a static body
|
|
261
260
|
* static body do not move automatically and do not check againt collision with others
|
|
262
261
|
* @name setStatic
|
|
263
|
-
* @
|
|
262
|
+
* @memberof me.Body
|
|
264
263
|
* @public
|
|
265
264
|
* @function
|
|
266
|
-
* @param {
|
|
265
|
+
* @param {boolean} [isStatic=true]
|
|
267
266
|
*/
|
|
268
267
|
setStatic(isStatic = true) {
|
|
269
268
|
this.isStatic = isStatic === true;
|
|
@@ -273,11 +272,11 @@ class Body {
|
|
|
273
272
|
* add a collision shape to this body <br>
|
|
274
273
|
* (note: me.Rect objects will be converted to me.Polygon before being added)
|
|
275
274
|
* @name addShape
|
|
276
|
-
* @
|
|
275
|
+
* @memberof me.Body
|
|
277
276
|
* @public
|
|
278
277
|
* @function
|
|
279
|
-
* @param {me.Rect|me.Polygon|me.Line|me.Ellipse|me.Bounds|
|
|
280
|
-
* @
|
|
278
|
+
* @param {me.Rect|me.Polygon|me.Line|me.Ellipse|me.Bounds|object} shape a shape or JSON object
|
|
279
|
+
* @returns {number} the shape array length
|
|
281
280
|
* @example
|
|
282
281
|
* // add a rectangle shape
|
|
283
282
|
* this.body.addShape(new me.Rect(0, 0, image.width, image.height));
|
|
@@ -327,11 +326,11 @@ class Body {
|
|
|
327
326
|
/**
|
|
328
327
|
* set the body vertices to the given one
|
|
329
328
|
* @name setVertices
|
|
330
|
-
* @
|
|
329
|
+
* @memberof me.Body
|
|
331
330
|
* @public
|
|
332
331
|
* @function
|
|
333
332
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
|
|
334
|
-
* @param {
|
|
333
|
+
* @param {number} [index=0] the shape object for which to set the vertices
|
|
335
334
|
* @param {boolean} [clear=true] either to reset the body definition before adding the new vertices
|
|
336
335
|
*/
|
|
337
336
|
setVertices(vertices, index = 0, clear = true) {
|
|
@@ -354,11 +353,11 @@ class Body {
|
|
|
354
353
|
/**
|
|
355
354
|
* add the given vertices to the body shape
|
|
356
355
|
* @name addVertices
|
|
357
|
-
* @
|
|
356
|
+
* @memberof me.Body
|
|
358
357
|
* @public
|
|
359
358
|
* @function
|
|
360
359
|
* @param {me.Vector2d[]} vertices an array of me.Vector2d points defining a convex hull
|
|
361
|
-
* @param {
|
|
360
|
+
* @param {number} [index=0] the shape object for which to set the vertices
|
|
362
361
|
*/
|
|
363
362
|
addVertices(vertices, index = 0) {
|
|
364
363
|
this.setVertices(vertices, index, false);
|
|
@@ -368,13 +367,13 @@ class Body {
|
|
|
368
367
|
* add collision mesh based on a JSON object
|
|
369
368
|
* (this will also apply any physic properties defined in the given JSON file)
|
|
370
369
|
* @name fromJSON
|
|
371
|
-
* @
|
|
370
|
+
* @memberof me.Body
|
|
372
371
|
* @public
|
|
373
372
|
* @function
|
|
374
|
-
* @param {
|
|
375
|
-
* @param {
|
|
373
|
+
* @param {object} json a JSON object as exported from a Physics Editor tool
|
|
374
|
+
* @param {string} [id] an optional shape identifier within the given the json object
|
|
376
375
|
* @see https://www.codeandweb.com/physicseditor
|
|
377
|
-
* @
|
|
376
|
+
* @returns {number} how many shapes were added to the body
|
|
378
377
|
* @example
|
|
379
378
|
* // define the body based on the banana shape
|
|
380
379
|
* this.body.fromJSON(me.loader.getJSON("shapesdef").banana);
|
|
@@ -412,11 +411,11 @@ class Body {
|
|
|
412
411
|
/**
|
|
413
412
|
* return the collision shape at the given index
|
|
414
413
|
* @name getShape
|
|
415
|
-
* @
|
|
414
|
+
* @memberof me.Body
|
|
416
415
|
* @public
|
|
417
416
|
* @function
|
|
418
|
-
* @param {
|
|
419
|
-
* @
|
|
417
|
+
* @param {number} [index=0] the shape object at the specified index
|
|
418
|
+
* @returns {me.Polygon|me.Line|me.Ellipse} shape a shape object if defined
|
|
420
419
|
*/
|
|
421
420
|
getShape(index) {
|
|
422
421
|
return this.shapes[index || 0];
|
|
@@ -425,9 +424,9 @@ class Body {
|
|
|
425
424
|
/**
|
|
426
425
|
* returns the AABB bounding box for this body
|
|
427
426
|
* @name getBounds
|
|
428
|
-
* @
|
|
427
|
+
* @memberof me.Body
|
|
429
428
|
* @function
|
|
430
|
-
* @
|
|
429
|
+
* @returns {me.Bounds} bounding box Rectangle object
|
|
431
430
|
*/
|
|
432
431
|
getBounds() {
|
|
433
432
|
return this.bounds;
|
|
@@ -436,11 +435,11 @@ class Body {
|
|
|
436
435
|
/**
|
|
437
436
|
* remove the specified shape from the body shape list
|
|
438
437
|
* @name removeShape
|
|
439
|
-
* @
|
|
438
|
+
* @memberof me.Body
|
|
440
439
|
* @public
|
|
441
440
|
* @function
|
|
442
441
|
* @param {me.Polygon|me.Line|me.Ellipse} shape a shape object
|
|
443
|
-
* @
|
|
442
|
+
* @returns {number} the shape array length
|
|
444
443
|
*/
|
|
445
444
|
removeShape(shape) {
|
|
446
445
|
// clear the current bounds
|
|
@@ -458,11 +457,11 @@ class Body {
|
|
|
458
457
|
/**
|
|
459
458
|
* remove the shape at the given index from the body shape list
|
|
460
459
|
* @name removeShapeAt
|
|
461
|
-
* @
|
|
460
|
+
* @memberof me.Body
|
|
462
461
|
* @public
|
|
463
462
|
* @function
|
|
464
|
-
* @param {
|
|
465
|
-
* @
|
|
463
|
+
* @param {number} index the shape object at the specified index
|
|
464
|
+
* @returns {number} the shape array length
|
|
466
465
|
*/
|
|
467
466
|
removeShapeAt(index) {
|
|
468
467
|
return this.removeShape(this.getShape(index));
|
|
@@ -473,11 +472,11 @@ class Body {
|
|
|
473
472
|
* but it's also possible to specify 'collision filters' to provide a finer <br>
|
|
474
473
|
* control over which entities can collide with each other.
|
|
475
474
|
* @name setCollisionMask
|
|
476
|
-
* @
|
|
475
|
+
* @memberof me.Body
|
|
477
476
|
* @public
|
|
478
477
|
* @function
|
|
479
478
|
* @see me.collision.types
|
|
480
|
-
* @param {
|
|
479
|
+
* @param {number} [bitmask = me.collision.types.ALL_OBJECT] the collision mask
|
|
481
480
|
* @example
|
|
482
481
|
* // filter collision detection with collision shapes, enemies and collectables
|
|
483
482
|
* myEntity.body.setCollisionMask(me.collision.types.WORLD_SHAPE | me.collision.types.ENEMY_OBJECT | me.collision.types.COLLECTABLE_OBJECT);
|
|
@@ -492,11 +491,11 @@ class Body {
|
|
|
492
491
|
/**
|
|
493
492
|
* define the collision type of the body for collision filtering
|
|
494
493
|
* @name setCollisionType
|
|
495
|
-
* @
|
|
494
|
+
* @memberof me.Body
|
|
496
495
|
* @public
|
|
497
496
|
* @function
|
|
498
497
|
* @see me.collision.types
|
|
499
|
-
* @param {
|
|
498
|
+
* @param {number} type the collision type
|
|
500
499
|
* @example
|
|
501
500
|
* // set the body collision type
|
|
502
501
|
* myEntity.body.collisionType = me.collision.types.PLAYER_OBJECT;
|
|
@@ -515,7 +514,7 @@ class Body {
|
|
|
515
514
|
* the built-in function to solve the collision response
|
|
516
515
|
* @protected
|
|
517
516
|
* @name respondToCollision
|
|
518
|
-
* @
|
|
517
|
+
* @memberof me.Body
|
|
519
518
|
* @function
|
|
520
519
|
* @param {me.collision.ResponseObject} response the collision response object
|
|
521
520
|
*/
|
|
@@ -555,10 +554,10 @@ class Body {
|
|
|
555
554
|
* - The index of element in the array. <br>
|
|
556
555
|
* - The array forEach() was called upon. <br>
|
|
557
556
|
* @name forEach
|
|
558
|
-
* @
|
|
557
|
+
* @memberof me.Body.prototype
|
|
559
558
|
* @function
|
|
560
559
|
* @param {Function} callback fnction to execute on each element
|
|
561
|
-
* @param {
|
|
560
|
+
* @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
|
|
562
561
|
* @example
|
|
563
562
|
* // iterate through all shapes of the physic body
|
|
564
563
|
* mySprite.body.forEach((shape) => {
|
|
@@ -592,20 +591,20 @@ class Body {
|
|
|
592
591
|
/**
|
|
593
592
|
* Returns true if the any of the shape composing the body contains the given point.
|
|
594
593
|
* @name contains
|
|
595
|
-
* @
|
|
594
|
+
* @memberof me.Body
|
|
596
595
|
* @function
|
|
597
596
|
* @param {me.Vector2d} point
|
|
598
|
-
* @
|
|
597
|
+
* @returns {boolean} true if contains
|
|
599
598
|
*/
|
|
600
599
|
|
|
601
600
|
/**
|
|
602
601
|
* Returns true if the any of the shape composing the body contains the given point.
|
|
603
602
|
* @name contains
|
|
604
|
-
* @
|
|
603
|
+
* @memberof me.Body
|
|
605
604
|
* @function
|
|
606
|
-
* @param {
|
|
607
|
-
* @param {
|
|
608
|
-
* @
|
|
605
|
+
* @param {number} x x coordinate
|
|
606
|
+
* @param {number} y y coordinate
|
|
607
|
+
* @returns {boolean} true if contains
|
|
609
608
|
*/
|
|
610
609
|
contains() {
|
|
611
610
|
var _x, _y;
|
|
@@ -635,11 +634,11 @@ class Body {
|
|
|
635
634
|
* Rotate this body (counter-clockwise) by the specified angle (in radians).
|
|
636
635
|
* Unless specified the body will be rotated around its center point
|
|
637
636
|
* @name rotate
|
|
638
|
-
* @
|
|
637
|
+
* @memberof me.Body
|
|
639
638
|
* @function
|
|
640
|
-
* @param {
|
|
639
|
+
* @param {number} angle The angle to rotate (in radians)
|
|
641
640
|
* @param {me.Vector2d|me.ObservableVector2d} [v=me.Body.getBounds().center] an optional point to rotate around
|
|
642
|
-
* @
|
|
641
|
+
* @returns {me.Body} Reference to this object for method chaining
|
|
643
642
|
*/
|
|
644
643
|
rotate(angle, v = this.getBounds().center) {
|
|
645
644
|
this.bounds.clear();
|
|
@@ -662,10 +661,10 @@ class Body {
|
|
|
662
661
|
/**
|
|
663
662
|
* cap the body velocity (body.maxVel property) to the specified value<br>
|
|
664
663
|
* @name setMaxVelocity
|
|
665
|
-
* @
|
|
664
|
+
* @memberof me.Body
|
|
666
665
|
* @function
|
|
667
|
-
* @param {
|
|
668
|
-
* @param {
|
|
666
|
+
* @param {number} x max velocity on x axis
|
|
667
|
+
* @param {number} y max velocity on y axis
|
|
669
668
|
* @protected
|
|
670
669
|
*/
|
|
671
670
|
setMaxVelocity(x, y) {
|
|
@@ -676,10 +675,10 @@ class Body {
|
|
|
676
675
|
/**
|
|
677
676
|
* set the body default friction
|
|
678
677
|
* @name setFriction
|
|
679
|
-
* @
|
|
678
|
+
* @memberof me.Body
|
|
680
679
|
* @function
|
|
681
|
-
* @param {
|
|
682
|
-
* @param {
|
|
680
|
+
* @param {number} x horizontal friction
|
|
681
|
+
* @param {number} y vertical friction
|
|
683
682
|
* @protected
|
|
684
683
|
*/
|
|
685
684
|
setFriction(x = 0, y = 0) {
|
|
@@ -763,10 +762,10 @@ class Body {
|
|
|
763
762
|
* At this time a call to Body.Update does not call the onBodyUpdate callback that is listed in the constructor arguments.
|
|
764
763
|
* @name update
|
|
765
764
|
* @ignore
|
|
766
|
-
* @
|
|
765
|
+
* @memberof me.Body
|
|
767
766
|
* @function
|
|
768
|
-
* @
|
|
769
|
-
* @
|
|
767
|
+
* @param {number} dt time since the last update in milliseconds.
|
|
768
|
+
* @returns {boolean} true if resulting velocity is different than 0
|
|
770
769
|
*/
|
|
771
770
|
update(dt) {
|
|
772
771
|
// update the velocity
|