#include <Animation.h>

Public Member Functions | |
| virtual void | setName (const std::string &name)=0 |
| virtual FrameType | getFrameType () const =0 |
| virtual void | setFrames (const std::vector< AnimationFrame > &frames)=0 |
| virtual const std::vector < AnimationFrame > & | getFrames () const =0 |
| virtual unsigned int | getNumFrames () const =0 |
| virtual bool | hasFrame (const AnimationFrame *pFrame) const =0 |
| virtual void | setCurrentFrame (const AnimationFrame *pFrame)=0 |
| virtual void | setCurrentFrame (double frameValue)=0 |
| virtual const AnimationFrame * | getCurrentFrame () const =0 |
| virtual double | getStartValue () const =0 |
| virtual double | getStopValue () const =0 |
| virtual double | getNextFrameValue (AnimationState direction, size_t offset=1) const =0 |
Static Public Member Functions | |
| static const std::string & | signalRenamed () |
| static const std::string & | signalFrameChanged () |
| static const std::string & | signalFramesChanged () |
Protected Member Functions | |
| virtual | ~Animation () |
An animation object provides the means by which other objects can be animated by providing a set of animation frames, one of which is identified as the current frame. An animation by itself does not provide a lot of functionality but simply notifies attached objects when its current frame is changed. The real work of a displaying an animation is therefore in those objects that attach to the animation object.
To create a useful animation, first create a class with a Slot method. This class should contain the logic needed to prepare frames for display. Next, create a vector of animation frames for times of interest to the animation. Create the animation by calling AnimationController::createAnimation(). Attach the class to the animation. Then in the class's Slot method, whenever signalFrameChanged() is the signal with a non-NULL value, this indicates that the current frame has changed. any_cast the value to an AnimationFrame pointer and perform any specific updates based on the new frame values.
An animation is both created and destroyed from an animation controller.
This subclass of Subject will notify upon the following conditions:
Definition at line 50 of file Animation.h.
| virtual Animation::~Animation | ( | ) | [protected, virtual] |
This should be destroyed by calling AnimationController::destroyAnimation.
Definition at line 236 of file Animation.h.
| static const std::string& Animation::signalRenamed | ( | ) | [static] |
Emitted with boost::any<std::string> when an Animation is renamed.
Definition at line 56 of file Animation.h.
| static const std::string& Animation::signalFrameChanged | ( | ) | [static] |
Emitted with boost::any<AnimationFrame*> when the current frame is changed.
Definition at line 60 of file Animation.h.
| static const std::string& Animation::signalFramesChanged | ( | ) | [static] |
Emitted with boost::any<std::vector<AnimationFrame> > when the list of frames in the animation changes.
Definition at line 64 of file Animation.h.
| virtual void Animation::setName | ( | const std::string & | name | ) | [pure virtual] |
Sets the animation name.
| name | The new name for the animation. |
| virtual FrameType Animation::getFrameType | ( | ) | const [pure virtual] |
Returns the type of frame value that the animation uses to set current frame.
This method returns whether the animation operates on frame numbers or time values when setting the current frame from a data value. The frame type is specified when the animation is created in AnimationController::createAnimation(). Once the animation is created, the frame type cannot be changed.
| virtual void Animation::setFrames | ( | const std::vector< AnimationFrame > & | frames | ) | [pure virtual] |
Sets the frame set that defines this animation.
This method sets a new frame set for the animation. Once the frames have been set, they are sorted in ascending order according to the frame number or the time value. The current frame is reset to the first frame in the internal sorted vector.
| frames | The new frame set for the animation. |
| virtual const std::vector<AnimationFrame>& Animation::getFrames | ( | ) | const [pure virtual] |
Returns the frame set that defines this animation.
| virtual unsigned int Animation::getNumFrames | ( | ) | const [pure virtual] |
Returns the total number of frames in the animation.
| virtual bool Animation::hasFrame | ( | const AnimationFrame * | pFrame | ) | const [pure virtual] |
Queries whether the animation contains a given frame.
This method does not check the contents of the given frame; it only checks if the pointer corresponds to the address of one of the internally stored frames. To check specific contents of a frame, use AnimationFrame::operator==() instead.
| pFrame | The frame to check for its existence in the animation. |
| virtual void Animation::setCurrentFrame | ( | const AnimationFrame * | pFrame | ) | [pure virtual] |
Sets the current frame in the animation.
This method is called primarily as a result of a currently playing animation controller. Calling it independently from the player will succeed and will have no effect on the player, but if the player's animation state is AnimationState::PLAY_FORWARD or AnimationState::PLAY_BACKWARD, this method will likely be called again soon by the animation controller. Therefore, it is only potentially useful to call this method when the player is paused or stopped.
| pFrame | The frame to set as the current frame. The given frame must exist in the animation. |
| virtual void Animation::setCurrentFrame | ( | double | frameValue | ) | [pure virtual] |
Sets the current frame in the animation.
This is a convenience method that allows an animation frame to be set as the current frame by specifying just the data value. The method identifies the first frame in the animation that is greater than or equal to the given frame value. The given frame value is compared with the internal frame values according to the animation's frame type to determine the frame to set as the current frame. Once the correct frame has been identified, the overloaded setCurrentFrame(const AnimationFrame*) method is called with the that frame.
If the given frame value is greater than the animation's stop value, the overloaded setCurrentFrame(const AnimationFrame*) method is called with a NULL value.
This method is called primarily as a result of a currently playing animation controller. Calling it independently from the player will succeed and will have no effect on the player, but if the player's animation state is PLAY_FORWARD or PLAY_BACKWARD, this method will likely be called again soon by the animation controller. Therefore, it is only potentially useful to call this method when the player is paused or stopped.
| frameValue | The frame value that will be used to set the current frame. The value should be of the same type as specified by getFrameType(). |
| virtual const AnimationFrame* Animation::getCurrentFrame | ( | ) | const [pure virtual] |
Returns the current frame in the animation.
| virtual double Animation::getStartValue | ( | ) | const [pure virtual] |
Returns the minimum frame value of all frames in the animation.
| virtual double Animation::getStopValue | ( | ) | const [pure virtual] |
Returns the maximum frame value of all frames in the animation.
| virtual double Animation::getNextFrameValue | ( | AnimationState | direction, | |
| size_t | offset = 1 | |||
| ) | const [pure virtual] |
Get the value of the next frame.
This method is used to find what the value will be for some offset away from the current frame. This method only counts unique frames, so a string of duplicate frames will count as 1 frame relative to the offset.
| direction | The direction to go. | |
| offset | The number of frames to offset. If direction is AnimationState::STOP or AnimationState::PAUSE_FORWARD or AnimationState::PAUSE_BACKWARD, this value is ignored. |
direction is AnimationState::STOP, AnimationState::PAUSE_FORWARD or AnimationState::PAUSE_BACKWARD, the value of the current frame is returned.