How does AnimationTimer work?

This is a quote from the documentation for the AnimationTimer class.

The AnimationTimer class allows you to create a timer that is called in every frame while it is active. An expanding class must override the method handle (long), which will be called in each frame. The start () and stop () methods let you start and stop the timer.

But I donโ€™t know how many frames are displayed every second, and when was the handle method called? before or after creating a frame.

And is it bad to use too much AnimationTimer in my application (Game)?

+4
source share
1 answer

How many frames javafx renders depends on the complexity of your program. The cap is approx. 60 frames per second, which is the common border of fps for applications. The method is called before the frame is displayed (you can check this by simply setting a breakpoint in the method).

Actually, for AnimationTimer, frames per second are often used. This blog post explains a lot:

http://tbeernot.wordpress.com/2011/11/12/javafx-2-0-bubblemark/

AnimationTimer can be used for a wide range of applications, and not just for animations. If a good or bad idea to use for your specific application cannot be determined without looking at the code itself. but for using AnimationTimer this is a good source to read:

http://blog.netopyr.com/2012/06/14/using-the-javafx-animationtimer/

+6
source

Source: https://habr.com/ru/post/1483750/


All Articles