get a smooth animation for a canvas game

后端 未结 3 1239
无人共我
无人共我 2020-12-21 05:19

How to get a better animation, dinamically, even when browser is busy or idle, for different devices which have different hardware capacity.

I have tried many ways a

3条回答
  •  春和景丽
    2020-12-21 05:35

    You should use requestAnimationFrame. It will queue up a callback to run on the next time the browser renders a frame. To achieve constant updating, call the update function recursively.

    var update = function(){

    //Do stuff

    requestAnimationFrame(update)

    }

提交回复
热议问题