领 对 算角度
let curX = Math.abs(x - this.x) //邻边 let curY = Math.abs(y - this.y)// 对边 let a = curX * curX //邻边平方 let b = curY * curY //对边平方 let curC = Math.sqrt(a + b)// 斜边 = 开平方根(邻边平方 + 对边平方) let iDistance = Math.sqrt(Math.pow((x - this.x), 2) + Math.pow((y - this.y), 2)); //斜边一步 let angle = Math.sin(curY / Math.sqrt(a + b)) // 角度 = sin(对边 / 斜边) angle = angle * 180 / 3.1415926 // 弧度转角度 Math.PI angle * 3.1415926 / 180 //角度转弧度 this.rotation = angle
let curX = this.tTarget.x - this.x
let curY = this.tTarget.y - this.y
let radian = Math.atan2(curY, curX)
let angle = radian * 180 / Math.PI //角度
let b = angle * Math.PI / 180 //在转弧度
let x = this.x + TeaPartyConfig.iSpeed * Math.cos(b) //算新的坐标
let y = this.y + TeaPartyConfig.iSpeed * Math.sin(b)