Skip to content
Kigs-framework edited this page Mar 1, 2023 · 4 revisions

Table of contents

ModuleTimer is one of the base modules. It gives access to the Timer class, and to the Ticker Upgrador.

Timer class

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.

Application Timer

When building a CoreApplication, the application timer is available with :

SP<Timer>& appTimer=KigsCore::GetCoreApplication()->GetApplicationTimer();

Ticker Upgrador

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");
  1. Getting Started

  2. Overall features

  3. Advances features

    3.1. CoreModifiable

    3.1.1. Upgrador

    3.2. Attributes

    3.3. Methods

    3.4. CoreItem

    3.5. Signal/Slot/Notification

    3.6. Lua Binding

    3.7. Data Driven Application

  4. 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

Clone this wiki locally