我正在迈出JavaFX的第一步。我想用javafx为很多图形元素(椭圆,贝塞尔曲线,而不是图像)制作动画。这些元素由大约10个元素组成,这些元素必须一起移动。我正在努力达到60 fps,我想要移动数以千计的这些元素。
至少有四种方法可以做到这一点:
我的问题是,这些方式中的哪一种(或另一种方式)是最快的方式?特别是,许多节点和组的使用是否会产生很高的性能影响?
答案 0 :(得分:5)
I would start with option two as this seems to logically fit your needs best. It is also the most straight forward and cleanest way of doing it with JavaFX. If it later turns out that the performance is not good enough you can try to improve this by using caching together with the appropriate cache hints. For example you can optimize your code for speed or for quality this way. This even works dynamically because you can switch between these cache hints depending on the state of your application. If you switch caching on for a group this has basically the same effect as drawing it into a canvas or an image.