鱼和鼠标的角度怎么反着旋转 求解啊 女神
鱼和鼠标的角度怎么反着旋转 。。
鱼和鼠标的角度怎么反着旋转 。。
2016-01-09
momObj.prototype.draw = function()
{
//console.log(this.x);
this.x = lerpDistance(mx,this.x,0.9);
this.y = lerpDistance(my,this.y,0.9);
//delta angle
var deltaY = my - this.y;
var deltaX = mx - this.x;
var beta = Math.atan2(deltaY,deltaX) + Math.PI;
this.angle = lerpAngle(beta,this.angle,0.9) ;
ctx1.save();
ctx1.translate(this.x,this.y);
ctx1.rotate(this.angle);
ctx1.drawImage(this.eye,-this.eye.width*0.5,-this.eye.height*0.5);
ctx1.drawImage(this.tail,-this.tail.width*0.5+30,-this.tail.height*0.5);
ctx1.drawImage(this.body,-this.body.width*0.5,-this.body.height*0.5);
ctx1.restore();
}
注意画大鱼眼睛,身体,尾巴的坐标,因为这个时候已经用了translate换了坐标
举报