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

后端 未结 10 1716
离开以前
离开以前 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:35

    Timer is inaccurate for controlling FPS in java. I have found that out second hand. You will need to implement your own timer or do real time FPS with limitations. But do not use Timer as it's not 100% accurate, and therefore cannot execute tasks properly.

提交回复
热议问题