// use this for initialization
onLoad: function () {
this.height = 640;
this.width = 1136;
this.lastPoint = cc.p(0,this.height);
},
//
update: function (dt) {
var curPoint = this.node.parent.getPosition();
if (this.curPoint == this.lastPoint) //
{
return ;
}
var dx = curPoint.x - this.lastPoint.x;
var dy = curPoint.y - this.lastPoint.y;
var angle = Math.atan(dx/dy);
var degree = angle*180/Math.PI;
if (degree) {
if(dy<0){
degree += 180;
}
cc.log(degree);
this.node.rotation = degree;
}
this.lastPoint = curPoint; //保存当前的坐标给下一轮刷新使用
},
网友评论