问答详情
源自:2-8 大鱼随鼠标移动

我的鱼为什么出不来啊,哭哭qwq

就是照着老师的敲的啊,鱼就不出现。。



var momObj = function(){

this.x;

this.y;

this.bigEye = new Image();

this.bigBody = new Image();

this.bigTail =new Image();

}

momObj.prototype.init = function(){

this.x = canWidth *0.5;

this.y = canHeight * 0.5;

this.bigEye.src = "/src/bigEye0.png";

this.bigBody.src = "/src/bigSwim0.png";

this.bigTail.src = "/src/bigTail0.png";

}

momObj.prototype.draw = function(){

this.x = lerpDistance(mx, this.x, 0.9);

this.y = lerpDistance(my, this.y , 0.9);

ctx1.save();

ctx1.translate(this.x,this.y);

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();

}


提问者:ZZZzyx 2018-11-25 13:03

个回答

  • qq_慕用6332897
    2020-11-20 11:43:16

    把ctx1换成2


  • 11学无止境11
    2018-11-26 14:43:13

    首先检查看看你的html文件有没有引入main.js, mom.js, 然后检查main.js有没有调用