+ 16

Please!!! Help me!

Look at my code named "Platform Game". It draws nothing on canvas and shows error. Pls help!

11th Mar 2017, 2:54 PM
Aydin
2 ответов
+ 3
you have not defined ctx
11th Mar 2017, 2:58 PM
Meharban Singh
Meharban Singh - avatar
+ 3
the error occours because you defined de ctx locally on window.onload. get the context globally, out of the function, like so: var can = document.createElement("canvas"); var ctx = can.getContext("2d"); window.onload = function(){ can.width = window.innerWidth; [...]
11th Mar 2017, 3:07 PM
Welliton Malta
Welliton Malta - avatar