def MouseDown(self, p): """ Indicates that there was a left click at point p (world coordinates) """ if self.mouseJoint != None: return # Create a mouse joint on the selected body (assuming it's dynamic) # Make a small box. aabb = box2d.b2AABB() d = box2d.b2Vec2(0.001, 0.001) aabb.lowerBound = p - d aabb.upperBound = p + d # Query the world for overlapping shapes. body = None k_maxCount = 10 # maximum amount of shapes to return (count, shapes) = self.world.Query(aabb, k_maxCount) for shape in shapes: shapeBody = shape.GetBody() if shapeBody.IsStatic() == False and shapeBody.GetMass() > 0.0: if shape.TestPoint(shapeBody.GetXForm(), p): # is it inside? body = shapeBody break if body: md = box2d.b2MouseJointDef() md.body1 = self.world.GetGroundBody() md.body2 = body md.target = p md.maxForce= 1000.0 * body.GetMass() self.mouseJoint = self.world.CreateJoint(md).getAsType() body.WakeUp()