animation - AnimationTimer 是如何工作的?

标签 animation javafx-2

这是引自 AnimationTimer类文档。

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



但我不知道每秒渲染多少帧,以及何时调用 handle 方法?在渲染帧之前或之后。

使用太多是不是坏主意AnimationTimer在我的应用程序(游戏)中?

最佳答案

javafx 渲染的帧数取决于程序的复杂性。上限约为。每秒 60 帧,这是应用程序常见的 fps 边界。该方法在显示帧之前调用(您可以通过简单地在方法中放置断点来检查)。

实际上,AnimationTimer 的常见用途是计算每秒的帧数。这个博客条目解释了很多:

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

AnimationTimer 可用于广泛的应用程序,而不仅仅是用于动画。如果不查看代码本身,就无法确定用于您的特定应用程序的好主意还是坏主意。但对于 AnimationTimer 的使用,这是一个很好的阅读来源:

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

关于animation - AnimationTimer 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16853711/

相关文章:

react-native - 如何在功能组件中编写Animated.Value.addListener?

listview - Javafx ListView刷新

JavaFX 2.0 + FXML。从不同的任务更新场景值

javafx-2 - 在JavaFX中设置TextField宽度

javafx-2 - 如何在 JavaFX 2.1 中更改光标图像大小?

JavaFx:如何同时在两个 GridPanes 节点上应用验证?

ios - 无法为 UISearchBar 的框架或边界设置动画

ios - 像 UIPageViewController 这样的自定义 ViewController Transition

android - 英雄动画上的 RenderFlex 溢出 - Flutter

iphone - 建立一个漂亮的进度条