很粗暴简单的去掉一半点。
首先确认MotionStreak组件里存了的 _renderData 里边的data应该是渲染使用的顶点数据,
按照途中的算法重新生成多边形数据(依次记录顶点数据)
然后将猫和狗的坐标转换到世界坐标,构建一个圆形数据,调用cc.Intersection.polygonCircle;
IntersectionCircle(circle) {
let data = this.tailMotionStreak["_renderData"]._data;
let L = data.length;
if (L < 2 * 4) {
return false;
}
let polygon = [];
let newL = L / 2;
let c = newL / 2;
for (let i = 0; i < c; i++) {
polygon[i] = data[4 * i + 1];
polygon[newL - i - 1] = data[4 * i];
}
return cc.Intersection.polygonCircle(polygon, circle)
}
不知道怎么代码高亮着色。