A class used to schedule and manage multiple animations.
More...
#include <gls_animation_juggler.h>
|
| GlsAnimationJuggler (Key currentTime=0) |
|
| ~GlsAnimationJuggler () |
| Destructor.
|
|
template<class Animation > |
ID | Schedule (Animation animation, DisplayFrame *displayFrame=0, LoopBehavior loop=PLAY_ONCE, double playbackSpeed=1, Key delayKey=0, Key startKey=Detail::g_nan, Key endKey=Detail::g_nan) |
|
template<class Animation , class Observer > |
ID | Schedule (Animation animation, Observer observer, DisplayFrame *displayFrame=0, LoopBehavior loop=PLAY_ONCE, double playbackSpeed=1, Key delayKey=0, Key startKey=Detail::g_nan, Key endKey=Detail::g_nan, typename Detail::enable_if< !Detail::is_convertible< Observer, DisplayFrame * >::value >::type *=0) |
|
void | Advance (Key dt) |
|
void | SetKey (Key key) |
|
void | Cancel (ID id) |
|
void | CancelAllAnimations () |
| Cancels all scheduled animations. No animation complete notifications are sent.
|
|
Key | GetKey (ID id) const |
|
|
static ID | GetInvalidID () |
| Gets the sentinel value for when scheduling fails.
|
|
A class used to schedule and manage multiple animations.
Specifies looping behaviors for animations.
Enumerator |
---|
PLAY_ONCE |
Plays the animation from its starting value to its ending value, and then removes the animation.
|
LOOP |
Plays the animation from its starting value to its ending value, and then wraps around to the starting value and repeats the cycle forever.
|
PING_PONG |
Plays the animation from its starting value to its ending value, and then from its ending value to its starting value, and repeats the cycle forever.
|
disti::GlsAnimationJuggler::GlsAnimationJuggler |
( |
Key |
currentTime = 0 | ) |
|
Constructor
- Parameters
-
currentTime | The key (usually calculation time) when the juggler is created. |
void disti::GlsAnimationJuggler::Advance |
( |
Key |
dt | ) |
|
Triggers the juggler to advance each animations by dt * animationData.playbackSpeed seconds. This should be called from the application's Calculate() function.
- Parameters
-
dt | The delta to advance from the last key set. |
- Note
- Any OnCompleteCallbacks associated with completed animations are called during this function call.
void disti::GlsAnimationJuggler::Cancel |
( |
ID |
id | ) |
|
Cancels the corresponding animation. No animation complete notifications are sent.
- Parameters
-
id | The animation ID to cancel. If it is not found, this call has no effect. |
Gets the current key (relative to the start of the animation) for specified animation.
- Parameters
-
id | The animation ID whose key will be fetched. |
template<class Animation >
ID disti::GlsAnimationJuggler::Schedule |
( |
Animation |
animation, |
|
|
DisplayFrame * |
displayFrame = 0 , |
|
|
LoopBehavior |
loop = PLAY_ONCE , |
|
|
double |
playbackSpeed = 1 , |
|
|
Key |
delayKey = 0 , |
|
|
Key |
startKey = Detail::g_nan , |
|
|
Key |
endKey = Detail::g_nan |
|
) |
| |
|
inline |
Schedule a new animation.
- Parameters
-
animation | The animation object, which must be convertible to GlsAnimation::Ptr. The juggler takes ownership of the animation (shared ownership if it is itself a shared_ptr). |
displayFrame | The displayFrame that contains the GL Studio objects to operate on. The juggler sets this as the display frame for the given animation. If null, the animation must have a display frame already set. |
loop | The loop behavior for this animation. |
playbackSpeed | The speed multiplier for this animation applied when Advance() or SetKey() is called. Can be negative. |
delayKey | Delay the start of this animation by this many key values. |
startKey | The key value to use as the start of this animation (endKey can be smaller than startKey) |
endKey | The key value to end up at at the end of this animation (endKey can be smaller than startKey) |
- Returns
- The id of the animation, for use in canceling. If equal to GetInvalidID(), then the scheduling operation failed and nothing was scheduled.
- Precondition
- animation != 0 && (displayFrame != 0 || animation->IsReadyToAnimate())
template<class Animation , class Observer >
Schedule a new animation with an animation observer.
- Parameters
-
animation | The animation object, which must be convertible to GlsAnimation::Ptr. The juggler takes ownership of the animation (shared ownership if it is itself a shared_ptr). |
observer | An observer class that receives a callback when the animation starts, updates, or completes. Must be convertible to GlsAnimationObserverBase::Ptr and not convertible to a DisplayFrame*. The juggler takes ownership of this object (shared ownership if it is itself a shared_ptr). See CreateOnCompletedCallback(), GlsAnimationObserver, etc. for more on creating callbacks. (Note: Cancelling an animation does not trigger a callback.). |
displayFrame | The display frame that contains the GL Studio objects to operate on, usually the pointer to an application or component. The juggler sets this as the display frame for the given animation. If null, the animation must have a display frame already set. |
loop | The loop behavior for this animation. |
playbackSpeed | The speed multiplier for this animation applied when Advance() or SetKey() is called. |
delayKey | Delay the start of this animation by this many key values. |
startKey | The key value to use as the start of this animation (endKey can be smaller than startKey) |
endKey | The key value to end up at at the end of this animation (endKey can be smaller than startKey) |
- Returns
- The id of the animation, for use in canceling. If equal to GetInvalidID(), then the scheduling operation failed and nothing was scheduled.
- Precondition
- animation != 0 && (displayFrame != 0 || animation->IsReadyToAnimate())
void disti::GlsAnimationJuggler::SetKey |
( |
Key |
key | ) |
|
Triggers the juggler to advance all animations by (key-lastKey) * GetPlaybackSpeed() seconds. This should be called from the application's Calculate() function.
- Parameters
-
key | The absolute key value to be applied, accounting for animation's starting key. |
- Note
- Any OnCompleteCallbacks associated with completed animations are called during this function call.
The documentation for this class was generated from the following files: