Images onload in one function
问题 I'm trying to learn JavaScript, making my first game. How I can make all images onload in one function and later draw it in the canvas making my code shorter? How can I put a lot of images in an array and later us it in a function. This is my third day of learning JavaScript. Thanks in advance. var cvs = document.getElementById('canvas'); var ctx = cvs.getContext('2d'); //load images var bird = new Image(); var bg = new Image(); var fg = new Image(); var pipeNorth = new Image(); var pipeSouth