Using Callbacks
A Callback schedules a method to be called at specific intervals. A Callback is composed of a Scheduler, which triggers at a defined interval. When the trigger occurs, the Callback object calls a particular method within a class. The Untold Engine provides a U4DEngine::U4DCallback object which represents a Callback.
Declare a U4DCallback
The snippet below shows how to declare a U4DCallback object. Usually, when using a U4DCallback, you will also need to declare a U4DEngine::U4DTimer.
Notice that the declaration of the U4DCallback requires the class name as its parameter. In this case, the class name represents the class that contains the method which the U4DCallback will call.
Create a U4DCallback
The snippet below shows how to create the U4DCallback and U4DTimer. Notice again, that the U4DCallback requires the name of the class upon creation. The U4DTimer requires the callback as its parameter.
Schedule the U4DCallback
To schedule the U4DCallback requires the Method name to call, a pointer to the U4DTimer, a time interval, and whether or not to call the method once, or repeatedly.
Delete the U4DCallback
Finally, in the class destructor, make sure to delete the U4DCallback and U4DTimer as follows.
Last updated