0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-08 23:03:36 -05:00

added Body.setStatic

This commit is contained in:
liabru 2014-04-23 16:51:14 +01:00
parent 1f11af9edb
commit 8acfdb7f38

View file

@ -108,15 +108,25 @@ var Body = {};
Axes.rotate(body.axes, body.angle);
Bounds.update(body.bounds, body.vertices, body.velocity);
if (body.isStatic) {
Body.setStatic(body, body.isStatic);
Sleeping.set(body, body.isSleeping);
};
/**
* Sets the body as static, including isStatic flag and setting mass and inertia to Infinity
* @method setStatic
* @param {bool} isStatic
*/
Body.setStatic = function(body, isStatic) {
body.isStatic = isStatic;
if (isStatic) {
body.restitution = 0;
body.friction = 1;
body.mass = body.inertia = body.density = Infinity;
body.inverseMass = body.inverseInertia = 0;
body.render.lineWidth = 1;
}
Sleeping.set(body, body.isSleeping);
};
/**