跟着老师的代码敲的,也引用到了main中了,为什么大鱼出不来,求教了!
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.drawImage(this.bigEye, this.x, this.y);
ctx1.drawImage(this.bigBody, this.x, this.y);
ctx1.drawImage(this.bigTail, this.x, this.y);
}
报错如下:mom.js:18 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.