跟著老師的代碼敲的,也引用到了main中了,為什么大魚(yú)出不來(lái),求教了!
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);
}
報(bào)錯(cuò)如下:mom.js:18 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
2017-02-25
this.bigEye.src = "/img/bigEye0.png";
this.bigBody.src = "/img/bigSwim0.png";
this.bigTail.src = "/img/bigTail0.png";
這個(gè)好像有問(wèn)題,少
加了. 吧
你改成這樣試試看
this.bigEye.src = "./img/bigEye0.png";
this.bigBody.src = "./img/bigSwim0.png";
this.bigTail.src = "./img/bigTail0.png";
2022-03-26
同學(xué)您好,對(duì)的,就是您這種寫(xiě)法就能將下標(biāo)和值同時(shí)取出來(lái)了!你可以參考一下“不會(huì)了怎么辦”里面的參考代碼
2017-02-28
看到下面的回答是把ctx1改成ctx2就可以了
我試過(guò)了