From cee8d55a323e2cc3e03afd496a1af978e4c2a786 Mon Sep 17 00:00:00 2001 From: liabru Date: Tue, 29 Jul 2014 13:26:20 +0100 Subject: [PATCH] added collisionFilter support to MouseConstraint --- src/constraint/MouseConstraint.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/constraint/MouseConstraint.js b/src/constraint/MouseConstraint.js index a3303ee..890b3a0 100644 --- a/src/constraint/MouseConstraint.js +++ b/src/constraint/MouseConstraint.js @@ -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); @@ -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 }; @@ -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 + */ + })(); \ No newline at end of file