I want display these images on canvas using SetInterval. so I want store them in an array but it does not work, because the images are not displayed on the canvas, which means the array is empty Is there any body with the idea on how to achieve that?
var imagesArr=[];
var n=0;
game.context.img1 = loader.loadImage("images/systems.png");
game.context.img2 = loader.loadImage("images/CPU.png");
game.context.img3 = loader.loadImage("images/abacus.png");
var image1 = game.context.img1;
var image2 = game.context.img2;
var image3 = game.context.img3;
imagesArr.push(image1);
imagesArr.push(image2);
imagesArr.push(image3);
"This is the answer to my question"
imgs=setInterval(function(){
n=(n+1)%imagesArr.length;
game.context.drawImage(imagesArr[n], 59, 220, 270, 260);
if (n>=2) clearInterval(imgs);
}, 2000);
imagesArr.push.image1? I don't know javascript, but shouldn't that beimagesArr.push(image1)?imagesArr.push(image1,image2,image3);