我正在学习如何使用 oracle tutorials 中的 JSlider
。我想用它来更改代码中变量的值,而不是更改动画的速度/fps。我注意到我在电脑游戏中看到的“每秒帧数”并阅读了 here 。我看到了不同的 JSlider 示例,它们都使用不同的 FPS 常量值。如何决定 JSlider FPS 常量使用哪些值?另外,为什么我们将它们设为常量而不是变量?我应该将这些值复制粘贴到所有使用 JSlider 的代码中吗?
static final int FPS_MIN = 0;
static final int FPS_MAX = 30;
static final int FPS_INIT = 15; //initial frames per second
. . .
JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,
FPS_MIN, FPS_MAX, FPS_INIT);
framesPerSecond.addChangeListener(this);
最佳答案
How do I decide which values to use for the JSlider FPS constants ?
这取决于您的要求。太慢而且动画看起来很糟糕。速度太快,电脑跟不上。无论如何,还只监视给定频率的刷新。我想我在另一篇文章中看到 60 是一个不错的最大值。
Should I just copy paste these values into all my code that uses JSlider ?
slider 可用于 FPS 功能以外的其他用途。因此,您选择的值取决于您的要求。
关于java - JSlider 中每秒帧数的重要性是什么以及选择什么值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15737080/