gpt4 book ai didi

animation - AnimationTimer 是如何工作的?

转载 作者:行者123 更新时间:2023-12-04 23:55:48 25 4
gpt4 key购买 nike

这是引自 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com