C4 Engine
C4 Engine API Documentation

Interpolator::SetLoopCallback

Defined in:  C4Time.h
Sets the loop callback function for an interpolator.
Prototype

void SetLoopCallback(LoopCallback *callback, void *cookie = nullptr);

Parameters
callback The new loop callback function.
cookie The cookie that is passed to the loop callback function.
Description
The SetLoopCallback function installs a callback function that is called when a looping interpolator reaches the end of one cycle and loops. An interpolator is looping if its current mode includes the kInterpolatorLoop flag. The loop callback function specified by the callback parameter should point to a function having the following prototype.

typedef void LoopCallback(Interpolator *, void *);

A pointer to the interpolator that has looped is passed as the first parameter to the callback function, and the value of the cookie parameter is passed as the second parameter.

An interpolator initially has no loop callback function. If the callback parameter is nullptr, then any existing loop callback function is removed from the interpolator.

If an interpolator's mode is equal to kInterpolatorForward | kInterpolatorLoop, then the loop callback function is called when the current value reaches the maximum value of the interpolator's range. If an interpolator's mode is equal to kInterpolatorBackward | kInterpolatorLoop, then the loop callback function is called when the current value reaches the minimum value of the interpolator's range. If the kInterpolatorOscillate flag is set in the current mode, then the loop callback function is called only when the current value is decreasing and reaches the minimum value of the interpolator's range.

It is safe to destroy an interpolator from inside the loop callback function.
See Also

Interpolator::GetMode

Interpolator::SetMode