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

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

    There is a lot of good information here already, but I wanted to share one problem that I had with these solutions, and the solution to that. If, despite all these solutions, your game/window seems to skip (especially under X11), try calling Toolkit.getDefaultToolkit().sync() once per frame.

提交回复
热议问题