Antkeeper  0.0.1
Public Member Functions | Protected Attributes | List of all members
animation_base Class Referenceabstract

Abstract base class for keyframe animations. More...

#include <animation.hpp>

Inheritance diagram for animation_base:
animation< float > animation< T >

Public Member Functions

 animation_base ()
 
virtual void advance (float dt)=0
 Advances the animation position (t) by dt. More...
 
void seek (float t)
 Sets the animation position to t. More...
 
void rewind ()
 Sets the animation position to 0.0. More...
 
void loop (bool enabled)
 Enables or disables looping of the animation. More...
 
void pause ()
 Pauses the animation. More...
 
void play ()
 Plays the animation. More...
 
void stop ()
 Stops the animation, rewinds it, and resets the loop count. More...
 
void set_speed (float speed)
 Sets the speed of the animation. More...
 
bool is_looped () const
 Returns true if looping of the animation is enabled, false otherwise. More...
 
bool is_paused () const
 Returns true if the animation is paused, false otherwise. More...
 
bool is_stopped () const
 Returns true if the animation is stopped, false otherwise. More...
 
float get_position () const
 Returns the current position in time of the animation. More...
 
int get_loop_count () const
 Returns the current loop count of the animation. More...
 
virtual float get_duration () const =0
 Returns the duration of the animation. More...
 
void set_start_callback (std::function< void()> callback)
 Sets the callback that's executed when the animation is started from a stopped state. More...
 
void set_end_callback (std::function< void()> callback)
 Sets the callback that's executed when a non-looped animation has finished. More...
 
void set_loop_callback (std::function< void(int)> callback)
 Sets the callback that's executed when the animation loops. More...
 

Protected Attributes

bool looped
 
int loop_count
 
bool paused
 
bool stopped
 
float position
 
float speed
 
std::function< void()> start_callback
 
std::function< void()> end_callback
 
std::function< void(int)> loop_callback
 

Detailed Description

Abstract base class for keyframe animations.

Definition at line 32 of file animation.hpp.

Constructor & Destructor Documentation

◆ animation_base()

animation_base::animation_base ( )

Definition at line 22 of file animation.cpp.

Member Function Documentation

◆ advance()

virtual void animation_base::advance ( float  dt)
pure virtual

Advances the animation position (t) by dt.

Parameters
dtDelta time by which the animation position will be advanced.

Implemented in animation< T >, and animation< float >.

◆ get_duration()

virtual float animation_base::get_duration ( ) const
pure virtual

Returns the duration of the animation.

Implemented in animation< T >, and animation< float >.

◆ get_loop_count()

int animation_base::get_loop_count ( ) const
inline

Returns the current loop count of the animation.

Definition at line 137 of file animation.hpp.

◆ get_position()

float animation_base::get_position ( ) const
inline

Returns the current position in time of the animation.

Definition at line 132 of file animation.hpp.

◆ is_looped()

bool animation_base::is_looped ( ) const
inline

Returns true if looping of the animation is enabled, false otherwise.

Definition at line 117 of file animation.hpp.

◆ is_paused()

bool animation_base::is_paused ( ) const
inline

Returns true if the animation is paused, false otherwise.

Definition at line 122 of file animation.hpp.

◆ is_stopped()

bool animation_base::is_stopped ( ) const
inline

Returns true if the animation is stopped, false otherwise.

Definition at line 127 of file animation.hpp.

◆ loop()

void animation_base::loop ( bool  enabled)

Enables or disables looping of the animation.

Definition at line 44 of file animation.cpp.

◆ pause()

void animation_base::pause ( )

Pauses the animation.

Definition at line 49 of file animation.cpp.

◆ play()

void animation_base::play ( )

Plays the animation.

Definition at line 54 of file animation.cpp.

◆ rewind()

void animation_base::rewind ( )

Sets the animation position to 0.0.

Definition at line 39 of file animation.cpp.

◆ seek()

void animation_base::seek ( float  t)

Sets the animation position to t.

Parameters
tPosition in time to which the animation position will be set.

Definition at line 34 of file animation.cpp.

◆ set_end_callback()

void animation_base::set_end_callback ( std::function< void()>  callback)

Sets the callback that's executed when a non-looped animation has finished.

Definition at line 87 of file animation.cpp.

◆ set_loop_callback()

void animation_base::set_loop_callback ( std::function< void(int)>  callback)

Sets the callback that's executed when the animation loops.

Parameters
callbackLoop callback function which is passed the current loop count.

Definition at line 92 of file animation.cpp.

◆ set_speed()

void animation_base::set_speed ( float  speed)

Sets the speed of the animation.

Parameters
speedSpeed multiplier.

Definition at line 77 of file animation.cpp.

◆ set_start_callback()

void animation_base::set_start_callback ( std::function< void()>  callback)

Sets the callback that's executed when the animation is started from a stopped state.

Definition at line 82 of file animation.cpp.

◆ stop()

void animation_base::stop ( )

Stops the animation, rewinds it, and resets the loop count.

Definition at line 69 of file animation.cpp.

Member Data Documentation

◆ end_callback

std::function<void()> animation_base::end_callback
protected

Definition at line 113 of file animation.hpp.

◆ loop_callback

std::function<void(int)> animation_base::loop_callback
protected

Definition at line 114 of file animation.hpp.

◆ loop_count

int animation_base::loop_count
protected

Definition at line 106 of file animation.hpp.

◆ looped

bool animation_base::looped
protected

Definition at line 105 of file animation.hpp.

◆ paused

bool animation_base::paused
protected

Definition at line 107 of file animation.hpp.

◆ position

float animation_base::position
protected

Definition at line 109 of file animation.hpp.

◆ speed

float animation_base::speed
protected

Definition at line 110 of file animation.hpp.

◆ start_callback

std::function<void()> animation_base::start_callback
protected

Definition at line 112 of file animation.hpp.

◆ stopped

bool animation_base::stopped
protected

Definition at line 108 of file animation.hpp.


The documentation for this class was generated from the following files: