我有一些关于matter.js库的代码,类似于以下内容:
// 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?");
}
});
在事件处理程序中,有没有办法告诉我哪个
boxA
boxB