小鱼游动问题
我按照老师的代码写的,怎么小鱼游动的方向不对?
我按照老师的代码写的,怎么小鱼游动的方向不对?
2016-02-17
babyObj.prototype.draw=function(){
this.x=lerpDistance(mx,this.x,0.98);
this.y=lerpDistance(my,this.y,0.98);
var deltay=mom.y-this.y;
var deltax=mom.x-this.x;
var beta=Math.atan2(deltay,deltax)+Math.PI;
this.angle=lerpAngle(beta,this.angle,0.6);
ctx1.save();
ctx1.translate(this.x,this.y);
ctx1.rotate(this.angle);
ctx1.drawImage(this.babyTail,-this.babyTail.width*0.5+23,-this.babyTail.height*0.5);
ctx1.drawImage(this.babyBody,-this.babyBody.width*0.5,-this.babyBody.height*0.5);
ctx1.drawImage(this.babyEye,-this.babyEye.width*0.5,-this.babyEye.height*0.5);
ctx1.restore();
}这是我的代码
举报