Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Clock countdown timer (solved)  (Read 5563 times)

0 Members and 1 Guest are viewing this topic.

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
sf::Clock countdown timer (solved)
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Clock countdown timer (solved)
« Reply #1 on: December 24, 2010, 09:01:56 am »
You should rather give a complete example, that we can test directly.
Laurent Gomila - SFML developer

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
sf::Clock countdown timer (solved)
« Reply #2 on: December 24, 2010, 06:28:15 pm »
I figured it out, thanks anyway  :) .