In my game I would likewant to be able to change the game speed of the time so that, to speed up or slow down all animations and gameplay is slowed down or speed up. Ideally, this speedcould also goes below zero so thatbe set to a negative number to make everything goesgo backwards.
Basically I havetried this:
I made everything dependent toon a timetime variable which I update, updated every frame using the time from the OS. time:
void calledEveryFrame()
{
time = System.accurateTime();
}
NowThen I tried the following but it didn't work:just scaling that time.
lastTime = time;
long now = System.accurateTime();
double diff = now - lastTime;
time = (lastTime + diff * speed);
That obviously doesn't work, because you can't just multiply the speed times the difference because it is not called exactly regularly.
How do I do this correctly?