Best way to implement game loop without freezing UI thread

前端 未结 3 1929
余生分开走
余生分开走 2021-01-12 01:10

I\'m trying to make a simple 2D game in Java.

So far I have a JFrame, with a menubar, and a class which extends JPanel and overrides it\'s

3条回答
  •  难免孤独
    2021-01-12 01:40

    Java is really suited for event-driven programming. Basically, set up a timer event and listen. At each 'tick-tock' you update your game logic. At each GUI-event you update your data structures that the game logic method will read.

提交回复
热议问题