diff --git a/src/body/Composite.js b/src/body/Composite.js index b814d7d..efbe6f3 100644 --- a/src/body/Composite.js +++ b/src/body/Composite.js @@ -192,8 +192,15 @@ var Body = require('./Body'); */ Composite.removeComposite = function(compositeA, compositeB, deep) { var position = Common.indexOf(compositeA.composites, compositeB); + if (position !== -1) { + var bodies = Composite.allBodies(compositeB); + Composite.removeCompositeAt(compositeA, position); + + for (var i = 0; i < bodies.length; i++) { + bodies[i].sleepCounter = 0; + } } if (deep) { @@ -244,8 +251,10 @@ var Body = require('./Body'); */ Composite.removeBody = function(composite, body, deep) { var position = Common.indexOf(composite.bodies, body); + if (position !== -1) { Composite.removeBodyAt(composite, position); + body.sleepCounter = 0; } if (deep) { @@ -296,6 +305,7 @@ var Body = require('./Body'); */ Composite.removeConstraint = function(composite, constraint, deep) { var position = Common.indexOf(composite.constraints, constraint); + if (position !== -1) { Composite.removeConstraintAt(composite, position); }