Skip to content

Commit

Permalink
changed Composte.removeComposite and Composte.removeBody to reset bod…
Browse files Browse the repository at this point in the history
…y.sleepCounter
  • Loading branch information
liabru committed Nov 25, 2023
1 parent 6f8a54b commit 6d10c3d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/body/Composite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6d10c3d

Please sign in to comment.