海葵怎么没动

来源:2-7 大鱼绘制

qq_筱萤火虫_0

2017-01-13 16:40

海葵怎么没动

写回答 关注

1回答

  • 慕雪9083869
    2017-03-13 16:00:38

    babyObj.prototype.draw = function () {
       // ctx1

       this.x = lerpDistance(mum.x, this.x, 0.98);
       this.y = lerpDistance(mum.y, this.y, 0.98);

       //delta angle
       var deltaY = mum.y - this.y;
       var deltaX = mum.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();
    }

HTML5小游戏---爱心鱼(上)

学做HTML5游戏,轻轻松松带你上手,适合刚入手游戏开发的同学

92353 学习 · 550 问题

查看课程

相似问题