Answer the question
In order to leave comments, you need to log in
Nuances about setTimeout/setInterval performance in relation to canvas?
Good day, toasters. I decided to start learning javascript more deeply, not limited to one jquery or other frameworks. I decided to write a small game using canvas and immediately the question arose of setting the dynamics. Definitely one cannot do without setTimeout and setInterval (although the latter is in doubt). But I just imagined how many elements that move at the same time, so I thought about how quickly the browser could handle rendering at short intervals (50-150 milliseconds, or maybe more often). What do you recommend in terms of possible rendering optimization? Should I start with dynamic fractal construction?
Answer the question
In order to leave comments, you need to log in
- Use 2-3 canvases superimposed on each other as layers;
- Cache in img everything that can be drawn in advance and use only drawImage() when drawing;
- Do not redraw everything that can not be redrawn.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question