diff --git a/demo/js/Demo.js b/demo/js/Demo.js index a5fcf91f..35092653 100644 --- a/demo/js/Demo.js +++ b/demo/js/Demo.js @@ -24,7 +24,8 @@ } // Matter aliases - var Example = Matter.Example, + var Body = Matter.Body, + Example = Matter.Example, Engine = Matter.Engine, World = Matter.World, Common = Matter.Common, @@ -295,6 +296,9 @@ demo.sceneEvents = []; // reset id pool + Body._nextCollidingGroupId = 1; + Body._nextNonCollidingGroupId = -1; + Body._nextCategory = 0x0001; Common._nextId = 0; // reset random seed diff --git a/src/body/Body.js b/src/body/Body.js index 144d4a4c..abeb777d 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -24,10 +24,9 @@ var Axes = require('../geometry/Axes'); (function() { Body._inertiaScale = 4; - - var _nextCollidingGroupId = 1, - _nextNonCollidingGroupId = -1, - _nextCategory = 0x0001; + Body._nextCollidingGroupId = 1; + Body._nextNonCollidingGroupId = -1; + Body._nextCategory = 0x0001; /** * Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults. @@ -100,9 +99,9 @@ var Axes = require('../geometry/Axes'); */ Body.nextGroup = function(isNonColliding) { if (isNonColliding) - return _nextNonCollidingGroupId--; + return Body._nextNonCollidingGroupId--; - return _nextCollidingGroupId++; + return Body._nextCollidingGroupId++; }; /** @@ -112,8 +111,8 @@ var Axes = require('../geometry/Axes'); * @return {Number} Unique category bitfield */ Body.nextCategory = function() { - _nextCategory = _nextCategory << 1; - return _nextCategory; + Body._nextCategory = Body._nextCategory << 1; + return Body._nextCategory; }; /**