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();
}
我还想不明白,跟你一样的问题
我想通了,哈哈,还是要分解问题,多看老师的编程思路才能衍生出自己的。不用大家给我回答了,