问答详情
源自:2-7 大鱼绘制

为什么我的大鱼没有显示出来

//大鱼

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="img/bigEye0.png";

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

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


}


momObj.prototype.draw=function()

{

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

}


提问者:慕前端7592895 2018-05-23 14:53

个回答

  • hjs9622
    2018-05-26 23:39:50

    是不是图片没有加载进来,也就是图片路径错误 应该是当前目录下的img文件./img/bigEye0.png

  • 幕布斯0246692
    2018-05-24 17:18:38

    把入口类贴出来~