-
Notifications
You must be signed in to change notification settings - Fork 22
Timer
ModuleTimer is one of the base modules. It gives access to the Timer class, and to the Ticker Upgrador.
Timer class inherits from CoreModifiable base class. A Timer instance compute the elapsed time since the instance is init.
The elapsed time can be retrieved in seconds using GetTime method.
double elapsedTime=mTimer.GetTime();
Elapsed time is also available using CoreModifiable getValue :
double elapsedTime=mTimer.getValue<double>("Time");
Timer instance can also manage time elapsed since last ask by a given class :
// get delta time for given instance
double dt=mTimer.GetDt(this);
Other utility methods are available as :
- void SetTime(double t) : set current time.
- State GetState() : get current state enum (UNINITIALISED, NORMAL, PAUSED).
- void SetState(State newstate) : change current state.
- void ResetDt(CoreModifiable* caller) : reset dt for the given caller.
- void GetDate(std::string& a_value, DateFormat a_format) const : get date as a string using given date format.
- void GetDate(unsigned int& a_year, unsigned int& a_month, unsigned int& a_day, unsigned int& a_hour, unsigned int& a_min, unsigned int& a_sec) const : get all values for the current date.
- void Sleep(unsigned int ms) : sleep this thread for given time in ms.
When building a CoreApplication, the application timer is available with :
SP<Timer>& appTimer=KigsCore::GetCoreApplication()->GetApplicationTimer();
Ticker Upgrador enable any CoreModifiable instance to call regularly, at a given frequency, a CoreModifiable method.
The instance is upgraded like this :
// upgrade instance
mInstance->Upgrade("TickerUpgrador");
// set frequency (calls per second)
mInstance->setValue("TickerFrequency", 4.0f);
// set called method
mInstance->setValue("TickerFunction", "calledMethod");
To stop the ticker, downgrade the instance :
// upgrade instance
mInstance->Downgrade("TickerUpgrador");
Kigs framework Wiki - kigs-framework.org
-
3.1. CoreModifiable
3.1.1. Upgrador
3.2. Attributes
3.3. Methods
3.4. CoreItem
3.6. Lua Binding
-
Other Modules
4.1. FileManager
4.2. Timer
4.3. 2DLayers
4.4. Collision
4.5. GUI
4.6. Input
4.7. SceneGraph
4.8. Renderer