I have built this game using HTML Canvas, but I seem to get this odd behaviour in Mozilla Firefox. I seem to be getting a flicker effect. A brief moment of white followed by everything being drawn. I assume this has something to do with clearRect, but I would like other opinions on what it could be?
I have built this game using HTML Canvas, but I seem to get this
Share
You are probably looking for a double buffering solution – don’t actually draw the canvas contents until you are done changing them. Using two canvas elements as suggested in Does HTML5/Canvas Support Double Buffering? should be indeed the best solution for games. If you create your “buffer canvas” dynamically and don’t actually add it to the document it should improve drawing performance (the browser won’t try to update the screen when you draw something to this canvas).