Frage

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

War es hilfreich?

Lösung

That may be caused by the garbage collector, using Adobe Scout should help you out trying to understand the problem.

If you don't want to use Adobe Scout, or if you just want to always have a little "benchmark" you can use https://github.com/mrdoob/Hi-ReS-Stats which will a little graph of the memory used and FPS which will help you to discover when the garbage collector "collects" (you'll see the memory used decreasing) and you can detect slow frames without using trace.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top