Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
148
rated 0 times [  155] [ 7]  / answers: 1 / hits: 86111  / 10 Years ago, sat, march 15, 2014, 12:00:00

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




Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.




Which makes NO SENSE at all, because the same code works in other places!?!



Here is an example I have in my code:



board.drawImage(document.getElementById(player_explode), this.x, this.y);


Inside of an objects method, Player.die(), respectively.



Does anyone know why this behaviour is coming about? I'm getting very frustrated about it...



Here is a JSFiddle to demonstrate, alonside all the code.
Player.die() is located on line[242].


More From » animation

 Answers
18

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


[#71971] Friday, March 14, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jananauticat

Total Points: 1
Total Questions: 105
Total Answers: 95

Location: Azerbaijan
Member since Fri, May 12, 2023
1 Year ago
;