问答详情
源自:1-2 鱼尾巴摆动

小鱼大鱼都不见

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

    ctx1.rotate(this.angle+60);

    ctx1.drawImage(babyTail[this.babyTailCount],-babyTail[this.babyTailCount].width * 0.5 + 25,-babyTail[this.babyTailCount].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();

提示我这段代码有问题:Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.

提问者:qq_一头会飞的翔_03623174 2017-05-08 21:00

个回答

  • 韩云涛
    2017-05-09 11:21:42

    应该是读不到正确的图片,你检查一下图片的路径是否正确,另外,在写 ctx1.drawImage(babyTail[this.babyTailCount],-babyTail[this.babyTailCount].width * 0.5 + 25,-babyTail[this.babyTailCount].height * 0.5);之前还要写var babyTailCount = this.babyTailCount;