Class that stores the progress of a sprite's animation.
More...
List of all members.
Public Member Functions |
| Animator () |
| Default constructor.
|
void | AddAnimation (const std::string &name, Animation::Ptr animation, sf::Time duration) |
| Registers an animation with a given name.
|
void | PlayAnimation (const std::string &name, bool loop=false) |
| Plays the animation with the given name.
|
void | StopAnimation () |
| Interrupts the animation that is currently active.
|
void | Update (sf::Time dt) |
| Updates the animator's progress. You should call this method each frame.
|
void | Animate (sf::Sprite &target) const |
| Applies the stored animations to a sf::Sprite.
|
void | SetDefaultAnimation (Animation::Ptr animation, sf::Time duration) |
| Sets an animation that is active when all others are stopped.
|
Detailed Description
Class that stores the progress of a sprite's animation.
The Animator class takes care of multiple Animation instances which are registered by a string. The registered animations can be played at any time. Animator updates their progress and applies it to sf::Sprite instances.
Member Function Documentation
Registers an animation with a given name.
- Parameters:
-
name | String to assign to the animation (may not be registered yet). |
animation | Animation to add to the animator. |
duration | Duration of the animation. |
Applies the stored animations to a sf::Sprite.
- Parameters:
-
target | Sprite whose subrect is changed according to the current animation. If no animation is active, the sprite is left unchanged or set to the static frame, if previously specified. |
Plays the animation with the given name.
- Parameters:
-
name | Name of the animation to play (std::string). An animation with this name must have been added before. |
loop | True if the animation is played repeatedly. |
Sets an animation that is active when all others are stopped.
- Parameters:
-
animation | Default animation to set. Will be played in a loop if no other animation is currently active. animation can be empty to reset the default animation. In this case, the sprite is not affected when no animation is playing. |
duration | Duration of the animation. |
Interrupts the animation that is currently active.
If a static frame has been specified, it is shown. Otherwise, the last visible frame of the stopped animation is shown.
Updates the animator's progress. You should call this method each frame.
- Parameters:
-
The documentation for this class was generated from the following file: