Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by landauf, 16 years ago) (diff)

Clock

TracNav(TracNav/TOC_Documentation)?

The clock class serves as an object that distributes time. It is created in RootGameState at the very beginning of start() which denotes the start of the game.
The capture() method then saves the current time. It can only be called by RootGameState.
In Order to get the current time, call getMicroseconds() and you will get the time stored by capture(). If you want to receive the current real time, call getRealMicroseconds(). This doesn't store the time however.

The idea is that the Clock object is handed over to every GameState via constant reference in the tick() method.[br] You should not attempt to use the Clock for the game level time. There is another class for that, which gets ticked too.

Method Description
getMicroseconds Absolute time since start() in us (stored)
getMilliseconds Absolute time since start() in ms (stored)
getSeconds Absolute time since start() in seconds (rounded, stored)
getSecondsPrecise Absolute time since start() in seconds as floating point number (stored)
getDeltaTime Relative time between the last two capture() calls in seconds as floating point number (stored)
getDeltaTimeMicroseconds Relative time between the last two capture() calls in micro seconds (stored)
getRealMicroseconds Absolute time since start() in us (not stored)