#include <papyrus/animator.h>
Inheritance diagram for Papyrus::Animator:
Public Types | |
typedef PapyrusSmartPointer< Animator > | pointer |
Class level smart pointer typedef. | |
Public Member Functions | |
virtual int | advance (int n=1) |
Advance the animation by n frames. | |
virtual int | reverse (int n=1) |
Reverse the animation by n frames. | |
virtual void | set_interval (unsigned int interval_ms) |
virtual unsigned int | interval () |
virtual double | frame_rate () |
virtual void | set_frame_rate (unsigned int frames_per_second) |
Sets the number of frames per second. | |
virtual void | start () |
virtual void | start (unsigned int interval_ms) |
virtual void | stop () |
virtual bool | is_started () |
int | bounce_frames () |
Returns the bounce frame setting. | |
int | bounce_direction () |
Returns the current bounce direction. | |
void | set_bounce_frames (int frames) |
Sets the number of 'bounce' frames. | |
sigc::signal< void, int > | signal_advanced () |
Protected Member Functions | |
bool | timeout_handler () |
virtual int | animate (int n)=0 |
Pure virtual method that children should implement to perform actual animation. | |
Protected Attributes | |
unsigned int | m_interval |
int | m_bounce_frames |
int | m_bounce_direction |
int | m_bounce_position |
guint | m_timeout_source_id |
sigc::signal< void, int > | m_signal_advanced |
void Papyrus::Animator::set_frame_rate | ( | unsigned int | frames_per_second | ) | [virtual] |
Sets the number of frames per second.
Since the interval is an integer is in milliseconds, and the set frames per second may not evenly divide 1000, the rounded result of 1000/frames_per_second is used.
For example, setting the frame rate to 30 would result in an interval of 33.333333. Therefore, an interval of 33 is used, yielding a frame rate of 33 frames per second.
int Papyrus::Animator::bounce_direction | ( | ) |
Returns the current bounce direction.
void Papyrus::Animator::set_bounce_frames | ( | int | frames | ) |
Sets the number of 'bounce' frames.
When set, the animation will proceed in a given direction and then reverse back to the original position creating a bounce effect. This allows a single callback point, such as advance()
to effectively work as a series of calls to advance()
followed by a series of calls to reverse()
.
The advantage of using the bounce effect is that you don't need to keep track of when to call advance()
and when to call reverse()
.
frames | Sets the number of bounce frames
|
virtual int Papyrus::Animator::animate | ( | int | n | ) | [protected, pure virtual] |
Pure virtual method that children should implement to perform actual animation.
n | The number of animation frames to perform
|