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

Author Topic: creating a spin-down timer  (Read 3873 times)

0 Members and 1 Guest are viewing this topic.

Bryston

  • Newbie
  • *
  • Posts: 8
    • View Profile
creating a spin-down timer
« on: March 20, 2013, 07:02:33 pm »
Any advice on how to create a spin-down timer?

Ive got an animation running at speed x and i want it to slowly spin down to 0 then stop

im pretty sure it is going to involve three elements like
sf::Clock sysClock;

sf::Time tInitial;
sf::Time tDelta;
sf::Time tTotal;

tInitial = sysClock.restart();
tDelta = sf::Seconds(0.02f);
tTotal = (some math operation combining tInitial and tDelta so i can ramp the animation down)
 

Im using Foalys animation class, so that may have a small/big influence on how to handle this problem.

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Re: creating a spin-down timer
« Reply #1 on: March 21, 2013, 07:39:32 pm »
I'm not really good an expert on this stuff. But wouldn't you have to either decrease a clocks increments? Not sure but, thought about it.  Makes sense for the moment :)
Noob C++ Programmer.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: creating a spin-down timer
« Reply #2 on: March 21, 2013, 08:11:24 pm »
thor::Timer ;)

But for logical time (as opposed to real time), you often don't want clocks, since they continue running when paused etc. A sf::Time variable that is continuously decreased may already suffice.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Lee R

  • Jr. Member
  • **
  • Posts: 86
    • View Profile
Re: creating a spin-down timer
« Reply #3 on: May 02, 2013, 12:00:29 am »
In the most general sense, what you're trying to describe is called "interpolation". The 'quadratic ease out' equation fits with the "slowing down" behaviour you're after.

http://gizma.com/easing/#quad2

Unfortunately, frame based animations tend to look like poop when you slow them down, because they cannot generate frames-between-frames. This is the raison d'ĂȘtre for inbetweening, aka tweening.

 

anything