Mouse.js mouse click on the body

Hello, if I have the following code for the matter.js library:

// create two boxes and a ground var boxA = Bodies.rectangle(400, 200, 80, 80); var boxB = Bodies.rectangle(450, 50, 80, 80); var ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true }); // add all of the bodies to the world World.add(engine.world, [boxA, boxB, ground]); Events.on(engine, 'tick', function(event) { if(mouseConstraint.mouse.button == 0){ alert("what is clicked?"); } }); 

Is there a way I can determine if the BoxA or boxB button was clicked with the mouse in the event handler?

+6
source share

Source: https://habr.com/ru/post/981985/


All Articles