nadako / Ash-Haxe

Port of Ash entity framework to Haxe
Other
131 stars 37 forks source link

FixedTickProvider incomplete? #37

Open jacobparis opened 7 years ago

jacobparis commented 7 years ago

I was looking at the code for FixedTickProvider and it just outputs a signal every frame no matter what the time adjustment or frametimer says. I replaced the code from that file with the code from FrameTickProvider and changed the dispatch function to

private function dispatchTick(event:Event):Void
    {
        var temp:Float = previousTime;
        var frameTime:Float = ( Lib.getTimer() - temp ) / 1000;
        while (frameTime > maximumFrameTime) { 
            previousTime = Lib.getTimer();
            signal.dispatch(frameTime * timeAdjustment);
            frameTime -= maximumFrameTime;
        }
    }

Now the second argument to the constructor defines how many frame-independent-seconds will elapse between signals.

new FixedTickProvider(container, 0.5); will dispatch a signal twice per second new FixedTickProvider(container, 5); will dispatch a signal once every five seconds

I'd be willing to make a pull request if this is the intended functionality of the class but I admit I don't know how