Adjusting Timer
-
I've had this feature for a few games but it's been a while and I can't seem to find it.
Basically what happens is this:
A timer is ticking down to 0.
When the timer hits 0, a function is called.
THEN after the timer hits 0, the timer is reset.HOWEVER, instead of being reset to it's old original time, each time it is reset, it loses a set amount of time. Say the original time was 10. When it resets, instead of 10, it's now 10-3. And it loses time on every reset.
Can someone do this for me? I can't remember how it's done.
Thanks.
-
Basically like this:
timer.onComplete = function(timer:FlxTimer) { timer.time -= time; // say time = 3 onTimerComplete(); }
-
Hmm. Why do you need to reset the timer manually? Can you just set the loops parameter to 0 (which means infinite)?
-
@starry-abyss Because I want to slowly increase the rate of enemy spawn. Say instead of every 20 seconds, it's now 18, or 12, or 10, etc.
@DleanJeans You can make the FlxTimer a public object???
public var timer:FlxTimer;
I thought you couldn't?
-
@xhunterko Why not?
-
@Gama11 Well. As per the example, and in examples I've seen. The timer is always called like this:
import flixel.util.FlxTimer; // time (seconds), callback, loops new FlxTimer().start(10.0, myCallback, 3); private function myCallback(Timer:FlxTimer):Void { }
So I was not sure how it is called.