SFML community forums

Help => System => Topic started by: AdventWolf on December 23, 2010, 11:34:39 pm

Title: sf::Clock countdown timer (solved)
Post by: AdventWolf on December 23, 2010, 11:34:39 pm
I created a timer just fine it my main menu state but I'm trying to create a countdown timer in different state but it isn't working. Though for some reason the Clock creates a huge number for ElapsedTime, so the countdown of 3 seconds only lasts a millisecond.

Here is what I have:
Code: [Select]

SwitchSong = 3.f;
DELAY_SONG = true;
...
ElapsedTime = Clock.GetElapsedTime();
Clock.Reset();

if( DELAY_SONG )
{
std::cout << "BEFORE: " << SwitchSong << std::endl;
SwitchSong -= ElapsedTime;
std::cout << "AFTER: " << SwitchSong << std::endl;
if( SwitchSong <= 0 )
{
BackGround.Stop();
BackGround2.Play();
BackGround2.SetLoop(true);
DELAY_SONG = false;
}
}


Thanks.
Title: sf::Clock countdown timer (solved)
Post by: Laurent on December 24, 2010, 09:01:56 am
You should rather give a complete example, that we can test directly.
Title: sf::Clock countdown timer (solved)
Post by: AdventWolf on December 24, 2010, 06:28:15 pm
I figured it out, thanks anyway  :) .