async randomPos(node: cc.Node,arr: any[]){
//_x要取的原坐标点
let _x = _F.getRandomNum(-1675*0.5+node.width*0.5,1675*0.5-node.width*0.5);
//遍历成员x轴250以内重叠重新随机
for (let index = 0; index < arr.length; index++) {
const element = arr[index];
const _pos =element.position
if(Math.abs(_x-_pos.x)<250){
this.scheduleOnce(function(){
this.randomPos(node,arr)
}, 0.01)
return
}
}
node.x = _x
arr.push(node)
}
个人笔记-随机坐标点不与其他物体坐标重合
最新推荐文章于 2023-04-24 15:18:17 发布