Greetings,
I have been going through some of the game examples and I noticed a Timer is used like this to evaluate player movement.
Timer {
id: updateTimer
interval: 60
running: true
repeat: true
onTriggered: {
// this must be done every frame, because the linearVelocity gets reduced because of the damping!
var xAxis = controller.xAxis;
if(xAxis) {
collider.body.linearVelocity.x = xAxis*rightValue;
}
}
}
Some of the design ideas I would like to experiment with involve tracking entities on a per frame basis (or close to it) so I set up a single game Timer{} like this in my GameWindow file and then coded some entities to utilize a Connection{} to connect a function to the Timer’s onTriggered() signal. It all seems to be working well.
Now I am looking at the interval you have set in the example (code above) and I am a little confused by the value. If the interval property is in ms and you have it set to 60 and the game is running at 60fps, to my understanding we would require the conversion of ms per frame. So in my mind (late at night) I am thinking the interval should be 1000ms/60fps which is approx a 17ms interval per trigger() of which close to 60 of them would be fired per second and more closely match the max frame rate.
-
This topic was modified 9 years, 3 months ago by
Xevoius.