thing.js鼠标点击身体

Ian*_*Ian 8 mouse

您好,如果我有一些类似于以下的问题,请访问:.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?");
        }
    });
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉我是否在事件处理程序中用鼠标点击了boxA或boxB?

tom*_*uyt 0

mouseConstraint.body包含被单击的正文。