老师,为什么rotate方法使用后,鱼的位置不跟着鼠标光标移动了,画布旋转,坐标系也旋转了吗??
momObj.prototype.draw = function(){
var deltaY=my-this.y;
var deltaX=mx-this.x;
var beta = Math.atan2(deltaY,deltaX);
//console.log(beta);
//this.x=this.x*Math.cos(this.lastbeta-beta)+this.x*Math.sin(this.lastbeta-beta);
//this.y=this.y*Math.sin(this.lastbeta-beta)+this.y*Math.cos(this.lastbeta-beta);
//beta=Math.PI/2;
//var mmx=mx*Math.cos(-beta)+my*Math.sin(-beta);
//var mmy=mx*Math.sin(-beta)+my*Math.cos(-beta);
this.x = lerpDistance(mx,this.x,0.9);
this.y = lerpDistance(my,this.y,0.9);
this.angle = lerpAngle(beta,this.angle,0.9);
console.log(this.angle);
ctx1.save();
ctx1.translate(canWidth*0.5,canHeight*0.5);
ctx1.rotate(this.angle);
ctx1.drawImage(this.body,this.x-this.body.width*0.5,this.y-this.body.height*0.5);
ctx1.drawImage(this.eye,this.x-this.eye.width*0.5,this.y-this.eye.height*0.5);
ctx1.drawImage(this.tail,this.x-this.tail.width*0.5+30,this.y-this.tail.height*0.5);
//this.lastbeta=beta;
ctx1.restore();
}