From d249165ea9e5a22758079e5be47bbb3a311b43b8 Mon Sep 17 00:00:00 2001 From: liabru Date: Thu, 1 Jan 2015 18:30:16 +0000 Subject: [PATCH] added Body.nextCategory --- src/body/Body.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/body/Body.js b/src/body/Body.js index 12aa8ec..ac4dd75 100644 --- a/src/body/Body.js +++ b/src/body/Body.js @@ -16,7 +16,8 @@ var Body = {}; Body._inertiaScale = 4; var _nextCollidingGroupId = 1, - _nextNonCollidingGroupId = -1; + _nextNonCollidingGroupId = -1, + _nextCategory = 0x0001; /** * Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults. @@ -89,6 +90,17 @@ var Body = {}; return _nextCollidingGroupId++; }; + /** + * Returns the next unique category bitfield (starting after the initial default category `0x0001`). + * There are 32 available. See `body.collisionFilter` for more information. + * @method nextCategory + * @return {Number} Unique category bitfield + */ + Body.nextCategory = function() { + _nextCategory = _nextCategory << 1; + return _nextCategory; + }; + /** * Initialises body properties. * @method _initProperties