六边形思路
1 向量
2 中心点 0,0
3 点1 100,0
4 点2 点1向量旋转60度 点3=点1向量旋转120度…
六边形点击响应
1 空节点(node)挂一个graphics组件
2 graphics组件画六边形
3 重写node._hitTest函数
4 将屏幕点击点转换成节点坐标系下的坐标点
5 坐标点与当前六边形顶点进行检测 cc.Intersection.pointInPolygon 点与多边形检测函数
_hitTest(point,listener){
let size = this.node.getContentSize();
let w = size.width;
let h = size.height;
let cameraPt;
let camera = cc.Camera.findCamera(this.node);
if(camera){
cameraPt = camera.getCameraToWorldPoint(point,cameraPt);
}else{
cameraPt = point;
}
//将世界点转换到局部坐标点
let p1 = this.node.parent.convertToNodeSpaceAR(cameraPt);
//cc.log(p1,this._points)
return cc.Intersection.pointInPolygon(p1,this._points)
// cc.log(p1);
// return true;
}