AnimationTimer如何工作? [英] How does AnimationTimer work?

查看:389
本文介绍了AnimationTimer如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是 AnimationTimer 类文档中的引用。


该类AnimationTimer允许创建一个计时器,该计时器在活动的每一帧中都会被调用。扩展类必须重写将在每一帧中调用的方法handle(long)。方法start()和stop()允许启动和停止计时器。

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方法?在帧渲染之前或之后。

But I don't know how many frames are rendered each second, and when the handle method has been called ? before frame being rendered or after.

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

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

推荐答案

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

How many frames javafx renders depends on the complexity of your program. The cap is at approx. 60 frames per second, which is a common fps border for applications. The method is called prior to the frame being displayed (you can check that by simply putting a breakpoint into the method).

实际上,它是AnimationTimer的常用用法计算每秒的帧数。该博客条目对很多内容进行了解释:

Actually, it is a common use for the AnimationTimer to count the frames per second. This blog entry explains a lot:

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

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

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

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

这篇关于AnimationTimer如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆