How do I cap my framerate at 60 fps in Java?

后端 未结 10 1711
离开以前
离开以前 2021-02-07 08:01

I am writting a simple game, and I want to cap my framerate at 60 fps without making the loop eat my cpu. How would I do this?

10条回答
  •  [愿得一人]
    2021-02-07 08:54

    The simple answer is to set a java.util.Timer to fire every 17 ms and do your work in the timer event.

提交回复
热议问题