//根据固定点,将捕捉到的鼠标事件,世界坐标转换成节点坐标 var position = this.node.parent.convertToNodeSpaceAR(e.getLocation()) // 该点所在的方位 (cos, sin) 获取方位 let direction:cc.Vec2=position.normalize(); //获取托盘半径 let r : number = cc.Vec2.distance(position,cc.v2(0,0)) //小车旋转角度 let radian = position.signAngle(cc.v2(1, 0)); //计算点击位置的弧度 let ang = radian / Math.PI * 180; //弧度制转换为角度值 this.car.getComponent("car").ang = -ang; //逆时针为正 //控制小车移动 this.car.getComponent("car").direction = direction this.node.setPosition(position) //小车: update () { //没有控制 if(this.direction==null){ return; } //旋转 this.node.angle = this.ang //移动 this.node.x += this.speed*this.direction.x this.node.y += this.speed*this.direction.y }