I'm wondering if there's a way to get the current x/y coordinates of a body when the mouse is clicked.
What I need to do is have the matter.js bodies be clickable, while retaining mouse interactivity for the element below the canvas. The idea I have is to set pointer-events: none; on the canvas, then whenever the parent element is clicked, check if the mouse position is within the bounds of an existing body (and modify the body's size if so).
Does this sound possible?
You can get the postion of a body with body.position.x and body.position.y. However I don't know how to get the width and height of a body.
You could do this using Query.point giving a mouse position and Composite.allBodies(engine.world). This will give you a list of bodies under the mouse, which you can then consult their body.position vectors.
Most helpful comment
You could do this using Query.point giving a mouse position and
Composite.allBodies(engine.world). This will give you a list of bodies under the mouse, which you can then consult theirbody.positionvectors.