碰撞检测面料js [英] collision detection fabrics js
本文介绍了碰撞检测面料js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Fabric js,我使用以下函数将图像放置在画布上,当我在画布上单击时,将图像放置在该位置上,我想知道是否可以通过某种方式检查天气已经存在于我点击的位置,特别是是否有其他图像
I am using fabric js, i use the following function to put an image on canvas, when i click on canvas an image is put on that location, i want to know if there is way that i can check weather there is something already present at location where i am clicking especially if there is another image or not
document.getElementById("door").onclick = function () {
canvas.on('mouse:down', function (o) {
fabric.Image.fromURL('http://localhost:60099/Images/door.png', function (img) {
var pointer = canvas.getPointer(o.e);
logo = img.set({ left: pointer.x , top: pointer.y })
canvas.add(logo);
canvas.item(objC).lockMovementY = true;
canvas.item(objC).lockMovementX = true;
canvas.renderAll();
});
});
}
推荐答案
可以使用fabric.js'intersectsWithObject'函数检测冲突.考虑他们的交叉点"示例:
Collisions can be detected with the fabric.js 'intersectsWithObject' function. Consider their 'intersection' example:
http://fabricjs.com/intersection
这篇关于碰撞检测面料js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文