0
\$\begingroup\$

After looking at some code sources out there I noticed Java Swing Games usually create a class implementing Runnable, create a new Thread and set up the game loop in the run() call.

But JavaFX games seem to simply extend from Application and run the game loop in a new AnimationTimer() { ... public void handle() ... }

What gives?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Application is part of JavaFX and therefore can't be used without it and since a JavaFX app relies on the lifecycle of this class and JavaFX requires a class that extends Application, it would be impossible to not use it when creating programs with the library.

\$\endgroup\$
1
  • \$\begingroup\$ Also, an Animation Timer automatically registers with the JavaFX pulse system (which has a dafault rate of 60fps, can be changed though) so it does the loopinp, timing and sleeping for you. \$\endgroup\$
    – Ignatiamus
    Apr 8, 2019 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .