I am making a game in JavaFX and have implemented a slider for controlling the game speed. I have a simple slider (javafx.scene.control.Slider) and I m binding the time attribute for the gameloop to the value I get from the slider.
The slider only really works when increasing the gamespeed. If i decrease it, the gameUpdate() will stop for a while - dependent on how much i decease it. If i increase the slider while waiting for the game to catch up, the game will continue again. Sometimes the game doesn t seem to catch up at all no matter how long i wait.
Is changing the keyframe time a bad idea in general or am i forgetting something else? I have been trying out changing the canSkip variable, and that seems to get the game running smoother when it starts again, but does not help me much.
def gameLoop:Timeline = Timeline{
repeatCount: Timeline.INDEFINITE
keyFrames: [
KeyFrame{
time: bind Duration.valueOf(Config.REFRESH_RATE_NUMBER - gameSpeed)
action: function(){
gameUpdate();
}
}
]//keyFrames[]
}// Timeline{}