君异
2016-04-02 10:19
momObj.prototype.draw=function()
{
this.x=lerpDistance(mx,this.x,0.99);//运动速度
this.y=lerpDistance(my,this.y,0.99);
var deltaY=my-this.y;//角度差
var deltaX=mx-this.x;
var beta = Math.atan2(deltaY,deltaX);
this.angel=lerpAngle(beta,this.angel,-0.6);
ctx1.save();//表示仅限于适用大鱼
ctx1.translate(this.x,this.y);//移动原点
ctx1.rotate(this.angel);
ctx1.drawImage(this.bigEye,-this.bigEye.width*0.5,-this.bigEye.height*0.5);
ctx1.drawImage(this.bigBody,-this.bigBody.width*0.5,-this.bigBody.height*0.5);
ctx1.drawImage(this.bigTail,-this.bigTail.width*0.5+30,-this.bigTail.height*0.5);
ctx1.restore();
}
var beta = Math.atan2(deltaY,deltaX);这里写成: var beta = Math.atan2(deltaY,deltaX)+Math.PI;
已解决,
var beta = Math.atan2(deltaY,deltaX);改成var beta = Math.atan2(-deltaY,-deltaX);
HTML5小游戏---爱心鱼(上)
92348 学习 · 551 问题
相似问题