JavaScript Failed to execute 'drawImage'

后端 未结 2 1708
梦如初夏
梦如初夏 2020-12-15 04:23

Ok so I\'m creating a game with JavaScript Canvas Elements and such. I\'ve been able to load in TONS of Images, but on a select few, JavaScript replies with Errors such as <

2条回答
  •  既然无缘
    2020-12-15 05:05

    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

提交回复
热议问题