您好,如果我有一些类似以下代码的问题:./s库:
// 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?
答案 0 :(得分:0)
mouseConstraint.body
包含被单击的正文。