@@ -38,6 +38,12 @@ class Countdown
3838 */
3939 static var countdownTimer : FlxTimer = null ;
4040
41+ /**
42+ * Secondary timers used when the Global Offset is set.
43+ * Sometimes the offset is larger than the beat crochet. In this case, timers are necessary.
44+ */
45+ static var countdownOffsetTimers : Array <FlxTimer > = [];
46+
4147 /**
4248 * Performs the countdown.
4349 * Pauses the song, plays the countdown graphics/sound, and then starts the song.
@@ -61,6 +67,12 @@ class Countdown
6167 // Handle onBeatHit events manually
6268 // @:privateAccess
6369 // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
70+ var offsetTimer : FlxTimer = null ;
71+ if (Conductor .instance .globalOffset != 0 )
72+ {
73+ offsetTimer = new FlxTimer ();
74+ countdownOffsetTimers .push (offsetTimer );
75+ }
6476
6577 // The timer function gets called based on the beat of the song.
6678 countdownTimer = new FlxTimer ();
@@ -80,10 +92,30 @@ class Countdown
8092 // PlayState.instance.dispatchEvent(new SongTimeScriptEvent(SONG_BEAT_HIT, 0, 0));
8193
8294 // Countdown graphic.
83- showCountdownGraphic (countdownStep );
95+ if (Conductor .instance .globalOffset >= 0 ) showCountdownGraphic (countdownStep );
96+ else
97+ offsetTimer .start (- Conductor .instance .globalOffset / Constants .MS_PER_SEC , (tmr ) ->
98+ {
99+ showCountdownGraphic (countdownStep );
100+ countdownOffsetTimers .remove (tmr );
101+
102+ tmr .cancel ();
103+ tmr .destroy ();
104+ tmr = null ;
105+ });
84106
85107 // Countdown sound.
86- playCountdownSound (countdownStep );
108+ if (Conductor .instance .globalOffset <= 0 ) playCountdownSound (countdownStep );
109+ else
110+ offsetTimer .start (Conductor .instance .globalOffset / Constants .MS_PER_SEC , (tmr ) ->
111+ {
112+ playCountdownSound (countdownStep );
113+ countdownOffsetTimers .remove (tmr );
114+
115+ tmr .cancel ();
116+ tmr .destroy ();
117+ tmr = null ;
118+ });
87119
88120 // Event handling bullshit.
89121 var cancelled : Bool = propagateCountdownEvent (countdownStep );
0 commit comments