I'm building a library in haxe/openfl to make games, and I've noticed some jerking in the movement of sprites, especially when running on android or flash set to debug, and after using trace(elapsed) on my code I noticed that there are spikes every few frames of a substantial amount, which I believe to be causeing the jerking:
Game.hx:64: 0.030999999999998806
**Game.hx:64: 0.0470000000000006**
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.03100000000000236
Game.hx:64: 0.03200000000000003
**Game.hx:64: 0.045999999999999375**
Game.hx:64: 0.03200000000000003
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.03100000000000236
Game.hx:64: 0.03200000000000003
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.03100000000000236
**Game.hx:64: 0.0470000000000006**
Game.hx:64: 0.03200000000000003
Game.hx:64: 0.030999999999998806
Game.hx:64: 0.030999999999998806
Here is the code used to determine the elapsed time:
private function UpdateElapsedTime()
{
var current = Lib.getTimer() / 1000.0;
elapsed = current - lastElapsed;
lastElapsed = current;
}
Can anyone point out what is going wrong, or what I could do to improve it, thanks, nico