问个小问题,cocos2dx 里如何求两个向量的夹角度数呀?
比如CCPoint a(1, 0), CCPoint b(1, 1); 那跟(0,0)的夹角应该是45度。
我看他有一个cppAngle(pt1,pt2)的函数,但结果怎么并不对呢?
或者知道余弦值怎么求度数呢?
根据Reference,cppAngle的返回值是弧度
cppAngle()方法返回的是弧度,你需要转化为角度。
CCPoint diff = ccpSub( ccp(s.width/2,s.height/2), start);
diff = ccpNormalize(diff);
CCLayerGradient *gradient = (CCLayerGradient*) getChildByTag(1);
gradient->setVector(diff);
这是在cocos2d-x上的一段代码 希望你能用的哦啊啊
根据Reference,cppAngle的返回值是弧度