I know you cannot simply use .gif on canvas so I guess drawing the image then clearing the image then having an interval of like half a second then doing the next image and so on.
Now this is what I've done, but I'm not sure I have got the interval right as I eant everything else on screen to move as is, even other animations running at this time. (think explosions in a game)
I tried this, but the intervals dont seem to work, it just draws everything one after another and clears the final one so you dont see anything.
var wide = 70;
var high = 70;
ctxExplosion.drawImage(spriteImage,0,1250,wide,high,100,100,wide,high);
setInterval(500);
ctxExplosion.clearRect(0,0,canvasWidth,canvasHeight);
ctxExplosion.drawImage(spriteImage,77,1250,wide,high,100,100,wide,high);
setInterval(500);
ctxExplosion.clearRect(0,0,canvasWidth,canvasHeight);
ctxExplosion.drawImage(spriteImage,150,1250,wide,high,100,100,wide,high);
setInterval(500);
ctxExplosion.clearRect(0,0,canvasWidth,canvasHeight);
ctxExplosion.drawImage(spriteImage,232,1250,wide,high,100,100,wide,high);
setInterval(500);
ctxExplosion.clearRect(0,0,canvasWidth,canvasHeight);
I want it so it will show like an animation, but also don't want the clearing of the layer to interfere with other explosions happening at the time. Any way around this?