intersects是Yuka js库中的一个方法,用于检测两个Cell对象之间是否有交集。
cell.intersects(otherCell)
otherCell:待检测的另一个Cell对象。如果两个Cell对象之间存在交集,则返回true,否则返回false。
const cell1 = new yuka.Cell(0, 0, 10, 10);
const cell2 = new yuka.Cell(5, 5, 10, 10);
cell1.intersects(cell2); // 返回 true
此方法受cell.group属性的影响,只会计算同一组内的Cell对象之间的交集。
如果两个Cell对象的边界刚好相切,也视为存在交集。