Swing timer - time fluctuating

前端 未结 3 614
陌清茗
陌清茗 2021-01-14 04:52

I am using a Swing Timer in my game but when the game is running it appears to have moments when it runs smoothly and moments when it slows down.

Why is the time fl

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-14 05:07

    The Swing Timer is notorious for its inaccuracy. Use something else instead.


    On prompting, I've decided to undelete this post. OTOH most of the extra information that makes it worth reinstating comes from trashgod, so I'll merely quote/paraphrase their comments.

    I'd argue that it's reasonably accurate but easy to saturate.

    And trashgod goes on to add in a separate comment that:

    (I) might cite Clock Quality. javax.swing.Timer isn't very accurate, but it has usefully precise resolution on modern platforms.

提交回复
热议问题