let _offv = cc.v2(this.n_node2.position.x - this.n_node1.position.x , this.n_node2.position.y - this.n_node1.position.y);
let _angle = Math.asin( _offv.normalizeSelf().cross(cc.v2(-1,0)));
不知道怎么求 我是这样写的但是不对
let _offv = cc.v2(this.n_node2.position.x - this.n_node1.position.x , this.n_node2.position.y - this.n_node1.position.y);
let _angle = Math.asin( _offv.normalizeSelf().cross(cc.v2(-1,0)));
不知道怎么求 我是这样写的但是不对
求大佬
有api: signAngle
不过返回的是弧度,你需要转一下角度
cc.misc.radiansToDegrees
看你可怜
var angle = Math.atan2((-y), (x)) //弧度
var theta = angle * (180 / Math.PI); //角度
楼上都是正解!
这个-y 和x 怎么算的
X轴正方向
用几个坐标点试一下不就知道了
//获取向量 角
getAngle(x1, y1, x2, y2) {
// 起点坐标
var begin = cc.v2(x1, y1);
// 终点坐标
var end = cc.v2(x2, y2);
// 起点到终点的方向向量
var dir = end.sub(begin);
// 计算夹角,这个夹角是带方向的
var angle = dir.signAngle(cc.v2(0, 1));
//将弧度转换为欧拉角
var degree = angle / Math.PI * 180;
return degree;
},
你这话说的~~~~
逗笑我了…
我现在发求助帖 一般都没人回了 所以感觉自己很可怜!!!