JavaScript Failed to execute 'drawImage'

烈酒焚心 提交于 2019-11-28 22:46:32
tanishalfelven

The problem was the way that I was loading my Images, I should've been doing:

var image = new Image();
image.src = "imagesource.jpg";

But instead I was get the elements by id from the document page.

Resources:

Explanation on loading images

Explanation on how html loads images

you should wait all elements load,so do like this:

window.onload=function(){
       board.drawImage(document.getElementById("player_explode"), this.x, this.y);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!