From 8acfdb7f38c812db5900891041a8ef09560dfc1f Mon Sep 17 00:00:00 2001 From: liabru Date: Wed, 23 Apr 2014 16:51:14 +0100 Subject: [PATCH] added Body.setStatic --- src/body/Body.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/body/Body.js b/src/body/Body.js index f8846f9..db57a4f 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -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); }; /**