您好,如果我有一些类似于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?
发布于 2018-11-04 05:29:27
mouseConstraint.body包含被单击的正文。
https://stackoverflow.com/questions/28324303
复制相似问题