Class Animator
Defined in File Animator.h
Nested Relationships
Nested Types
Class Documentation
-
class Animator
The Animator class is responsible for handling all animations of objects that inherit from AnimatableObject In the system there can be more than one Animator running at the same time.
Public Functions
-
void add(AnimatableObject *animationToAdd)
Add an animatable object to the Animator. The object is then updated by it.
- Parameters:
animationToAdd – Pointer to the object whose animations should be handled by this animator.
-
void remove(AnimatableObject *animationToRemove)
Remove an animatable object from the Animator. The object is then no longer updated by it.
- Parameters:
animationToRemove – Pointer to the object whose animations should not be handled anymore by this animator.
- Pre:
The object must have been added earlier by using Animator::add
-
void handle(uint32_t state = -1)
To be called periodically as fast as possible. Updates all animation states of all #AnimatableObjects assigned to this Animator.
- Parameters:
state – if not -1 any animations currently running are going to be set to an exact state
-
void setAnimation(AnimatableObject *object, AnimatableObject::AnimationFunction animationEffect, uint16_t duration, EasingBase *easing = nullptr, uint8_t fps = ANIMATION_TARGET_FPS)
Setup all parameters for an animation of an object assigned to this Animator but do not start it.
- Parameters:
object – Object for which to change the animation for
animationEffect – Animation effect that should be used next time an animation for this object is started.
duration – Total duration of the animation effect once it is started.
easing – [optional] default = NO_EASING; Easing effect to apply “on top” of the animation
fps – [optional] default = ANIMATION_TARGET_FPS; Target FPS to run the animation at
-
void startAnimation(AnimatableObject *object, AnimatableObject::AnimationFunction animationEffect, uint16_t duration, EasingBase *easing = nullptr, uint8_t fps = ANIMATION_TARGET_FPS)
Setup all parameters for an animation of an object assigned to this Animator and start it right away.
- Parameters:
object – Object for which to start the animation for
animationEffect – Animation effect that should be started
duration – Total duration of the animation effect
easing – [optional] default = NO_EASING; Easing effect to apply “on top” of the animation
fps – [optional] default = ANIMATION_TARGET_FPS; Target FPS to run the animation at
-
void startAnimation(AnimatableObject *object, AnimatableObject::AnimationFunction animationEffect, EasingBase *easing = nullptr)
Setup the most important parameters for an animation of an object assigned to this Animator and start it right away.
- Parameters:
object – Object for which to start the animation for
animationEffect – Animation effect that should be started
easing – [optional] default = NO_EASING; Easing effect to apply “on top” of the animation
-
void startAnimation(AnimatableObject *object)
Starts an animation which was previously setup.
- Parameters:
object – Object for which to start the animation for
- Pre:
An animation must already be setup for this object. Either though a call of Animator::setAnimation or a previous Animator::startAnimation call.
-
void setAnimationDuration(AnimatableObject *object, uint16_t duration)
Set the animation duration of an object assigned to this Animator.
- Parameters:
object – Object for which to set the suration for
duration – Total animation duration in ms once it is started.
-
void stopAnimation(AnimatableObject *object)
Calls the AnimatableObject::stop function on the given object.
- Parameters:
object – Object for which to stop the animation for
-
void resetAnimation(AnimatableObject *object)
Calls the AnimatableObject::reset function on the given object.
- Parameters:
object – Object for which to reset the animation for
-
AnimatableObject::AnimationFunction getAnimationEffect(AnimatableObject *object)
Get the current animation effect of the object.
- Parameters:
object – Object for which to get the current animation for
- Returns:
AnimatableObject::AnimationFunction pointer to the current animation effect function
-
ComplexAnimationInstance *PlayComplexAnimation(ComplexAmination *animation, AnimatableObject *animationObjectsArray[], bool looping = false)
Starts a complex chain of animations.
- Parameters:
animation – pointer to the animation that shall be played
animationObjectsArray – Array of the objects that shall be animated. The indices for the array are defined in the animation itself
looping – Whether the animation shall be looped or not
- Returns:
uint32_t The animation ID of the newly started animation -1 which results to the max 32 bit value represents an error while starting the animation
-
ComplexAnimationInstance *BuildComplexAnimation(ComplexAmination *animation, AnimatableObject *animationObjectsArray[], bool looping = false)
Builds a complex animation but does not start it.
- Parameters:
animation – pointer to the animation that shall be played
animationObjectsArray – Array of the objects that shall be animated. The indices for the array are defined in the animation itself
looping – Whether the animation shall be looped or not
- Returns:
uint32_t The animation ID of the newly started animation -1 which results to the max 32 bit value represents an error while starting the animation
-
void setComplexAnimationStep(ComplexAnimationInstance *animationInst, uint8_t step, uint32_t state)
set a complex animation to a specific step and state
- Parameters:
animationInst – animation to use, retrived by calling Animator::BuildComplexAnimation
step – Step of the complex animation which shall be executed
state – state of the current step
-
void ComplexAnimationStopLooping(ComplexAnimationInstance *animationInst)
disables looping of the complex animation so that it sops running after the current cycle is done running
- Parameters:
animationID – ID of the animation which shall be stopped
-
void WaitForComplexAnimationCompletion(ComplexAnimationInstance *animationInst)
Blocks exectution of further code until the currently running animation is complete.
- Parameters:
animationID – ID of the animation which shall be waited for
-
void delay(uint32_t delayInMs)
Delays further execution of code without blocking any currently ongoing animations.
- Parameters:
delayInMs – time to wait before moving on in ms
-
struct animationStep
Configuration structure used in the linked list to construct an animation chain.
Note
All three lists have to have the same length. The length also must be consistent across all animation steps. If the system crashes when calling an animation it is most likeley due to missing arrays or missmatched array lengths.
- Param arrayIndex:
index of the array position where the objects that shall be animated is located. Set to -1 to ignore
- Param animationEffects:
array of animation effects that shall be played back
- Param easingEffects:
array of easing effect (“modifiers”) that shall be applied to the animation
Public Members
-
int16_t *arrayIndex
-
AnimatableObject::AnimationFunction *animationEffects
-
EasingBase **easingEffects
-
struct ComplexAmination
Configuration structure for a complex animation.
Note
All list elements must have the same array length
- Param animationComplexity:
Maximum of how many animations can be triggered at the same time
- Param LengthPerAnimation:
How long one of the animations in the chain should last for
- Param animations:
list of animation steps that shall be played in sequence
Public Members
-
uint8_t animationComplexity
-
uint16_t LengthPerAnimation
-
LinkedList<animationStep*> *animations
-
struct ComplexAnimationInstance
Public Members
-
ComplexAmination *animation
-
bool loop
-
uint16_t counter
-
AnimatableObject **objects
-
bool running
-
ComplexAmination *animation
-
void add(AnimatableObject *animationToAdd)