AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
Polled timer. More...
#include <CzTimer.h>
Public Member Functions | |
void | setCurrentTime (float time) |
float | getCurrentTime () const |
void | setDuration (float duration) |
float | getDuration () const |
void | setRepeatCount (int count) |
int | getRepeatCount () const |
void | setAutoDelete (bool auto_delete) |
bool | isAutoDelete () const |
void | start () |
void | stop () |
void | restart () |
bool | isRunning () const |
CzEventManager * | getEventsManager () |
CzXomlTimer () | |
virtual | ~CzXomlTimer () |
bool | Update (float dt) |
Updates the timer. | |
void | ProcessEventActions (unsigned int event_name) |
Process the event actions described by event_name. | |
void | NotifyTimeout () |
void | NotifyRepeat () |
int | LoadFromXoml (IzXomlResource *parent, bool load_children, CzXmlNode *node) |
Creates an instance of this class from XOML. | |
Protected Member Functions | |
void | addEventsManager () |
Protected Attributes | |
bool | Running |
Timer running status. | |
float | CurrentTime |
Current timer time. | |
float | Duration |
Duration of timer. | |
int | RepeatCount |
Number of times to repeat before stopping, 0 means repeat forever. | |
int | OriginalRepeatCount |
Original number of times to repeat before stopping. | |
bool | AutoDelete |
If set to true then this timer will de4stroy itself when it times out. | |
CzEventManager * | EventsManager |
List of events that the timer handles. |
Polled timer.
Time plays a very important role in app and game development. Time allows us to perform useful tasks such as time events, fire off events at regular intervals and stabilise animations etc..
CzXomlTimer provides a software based timer mechanism for timing events as well a static method for retrieving the current time in milliseconds. Timers will not automatically fire off events when they expire, instead they have to be polled.
Timers provide additional functionality for calculating how much time is left on the timer as well as how much time has expired since the timer was started.
Timers don't really have much of an overhead so you can create as many as you like.
To retrieve the current time in milliseconds CzXomlTimer provides a static method:
uint64 GetCurrentTimeMs()
To retrieve the current time in UTC (universal coordinated time) CzXomlTimer provides a static method:
int64 GetCurrentTimeUTC()
Creating a timer is a simple case of declaring or allocating a CzXomlTimer then setting it off going. To check the timer you then poll it to check to see if it has timed out. Here's an example:
// Create a timer that expires after 10 seconds CzXomlTimer BusyTimer; BusyTimer.setDuration(10000); // Check to see if the timer has timed out if (BusyTimer.HasTimedOut()) { }
Timers can be reset, stopped and started using Reset(), Stop() and Start().
CzXomlTimer::CzXomlTimer | ( | ) | [inline] |
CzXomlTimer::~CzXomlTimer | ( | ) | [virtual] |
void CzXomlTimer::addEventsManager | ( | ) | [protected] |
float CzXomlTimer::getCurrentTime | ( | ) | const [inline] |
float CzXomlTimer::getDuration | ( | ) | const [inline] |
CzEventManager* CzXomlTimer::getEventsManager | ( | ) | [inline] |
int CzXomlTimer::getRepeatCount | ( | ) | const [inline] |
bool CzXomlTimer::isAutoDelete | ( | ) | const [inline] |
bool CzXomlTimer::isRunning | ( | ) | const [inline] |
int CzXomlTimer::LoadFromXoml | ( | IzXomlResource * | parent, |
bool | load_children, | ||
CzXmlNode * | node | ||
) | [virtual] |
Creates an instance of this class from XOML.
LoadFromXoml is the main method used by all classes that can be instantiated from XOML mark-up. This method creates an instance of this class from the supplied XML node structure specified by node.
[in] | parent | If non-null, the parent. |
load_children | true to load child nodes. | |
[in] | node | If non-null, the XOML markup node that defines this object |
Implements IzXomlResource.
void CzXomlTimer::NotifyRepeat | ( | ) |
void CzXomlTimer::NotifyTimeout | ( | ) |
void CzXomlTimer::ProcessEventActions | ( | unsigned int | event_name | ) |
Process the event actions described by event_name.
Processes the actions list that is associated with the event named event_name (event_name is a hash of the actual event name to speed up searches)
event_name | Name of the event as a string hash |
void CzXomlTimer::restart | ( | ) | [inline] |
void CzXomlTimer::setAutoDelete | ( | bool | auto_delete | ) | [inline] |
void CzXomlTimer::setCurrentTime | ( | float | time | ) | [inline] |
void CzXomlTimer::setDuration | ( | float | duration | ) | [inline] |
void CzXomlTimer::setRepeatCount | ( | int | count | ) | [inline] |
void CzXomlTimer::start | ( | ) | [inline] |
void CzXomlTimer::stop | ( | ) | [inline] |
bool CzXomlTimer::Update | ( | float | dt | ) |
Updates the timer.
dt | The number of seconds since physics was last updated |
bool CzXomlTimer::AutoDelete [protected] |
If set to true then this timer will de4stroy itself when it times out.
float CzXomlTimer::CurrentTime [protected] |
Current timer time.
float CzXomlTimer::Duration [protected] |
Duration of timer.
CzEventManager* CzXomlTimer::EventsManager [protected] |
List of events that the timer handles.
int CzXomlTimer::OriginalRepeatCount [protected] |
Original number of times to repeat before stopping.
int CzXomlTimer::RepeatCount [protected] |
Number of times to repeat before stopping, 0 means repeat forever.
bool CzXomlTimer::Running [protected] |
Timer running status.