Skip to content

Commit

Permalink
added collisionFilter support to MouseConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 29, 2014
1 parent 5060c76 commit cee8d55
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/constraint/MouseConstraint.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ var MouseConstraint = {};
mouse: mouse,
dragBody: null,
dragPoint: null,
constraint: constraint
constraint: constraint,
collisionFilter: {
category: 0x0001,
mask: 0xFFFFFFFF,
group: 0
}
};

var mouseConstraint = Common.extend(defaults, options);
Expand Down Expand Up @@ -72,7 +77,8 @@ var MouseConstraint = {};
for (var i = 0; i < bodies.length; i++) {
var body = bodies[i];
if (Bounds.contains(body.bounds, mouse.position)
&& Vertices.contains(body.vertices, mouse.position)) {
&& Vertices.contains(body.vertices, mouse.position)
&& Detector.canCollide(body.collisionFilter, mouseConstraint.collisionFilter)) {
constraint.pointA = mouse.position;
constraint.bodyB = body;
constraint.pointB = { x: mouse.position.x - body.position.x, y: mouse.position.y - body.position.y };
Expand Down Expand Up @@ -196,4 +202,13 @@ var MouseConstraint = {};
* @type constraint
*/

/**
* An `Object` that specifies the collision filter properties.
* The collision filter allows the user to define which types of body this mouse constraint can interact with.
* See `body.collisionFilter` for more information.
*
* @property collisionFilter
* @type object
*/

})();

0 comments on commit cee8d55

Please sign in to comment.