1
System / Finding Delta time in SFML 2.0
« on: February 19, 2012, 05:06:16 pm »
Thank you! Using AsSeconds did the trick. As for using a vector, I.. don't know why I'm not using them.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
sf::Time currentTime;
//get current elapsed time of frame
currentTime = deltaClock.GetElapsedTime();
deltaTime = ( currentTime - prevDeltaTime );
prevDeltaTime = currentTime;
deltaClock.Restart();
void Asteroid::animate()
{
if ( frame == frames.end() ) frame = frames.begin();
//if frame time has elapsed, move to next frame in animation
if ( frameClock.GetElapsedTime().AsMilliseconds() >= frameTime.AsMilliseconds() )
{
mySprite.SetTextureRect(*frame); //set frame
++frame;
//reset clock
frameClock.Restart();
}
}