82
rated 0 times
[
87]
[
5]
/ answers: 1 / hits: 34715
/ 10 Years ago, wed, june 25, 2014, 12:00:00
This is my HTML code, showing the canvas:
<canvas id=backgroundCanvas width=550 height=600></canvas>
<canvas id=playerCanvas width=550 height=600></canvas
<canvas id=enemiesCanvas width=550 height=600></canvas>
This is where the problem is said to occur:
game.contextBackground = document.getElementById(backgroundCanvas).getContext(2d); // line 32
game.contextPlayer = document.getElementById(playerCanvas).getContext(2d); // line 33
game.contextEnemies = document.getElementById(enemiesCanvas).getContext(2d); // line 34
the error occurs on line 34 where it says:
Uncaught TypeError: Cannot read property 'getContext' of null
any help is much appreciated :)
More From » jquery