Bromeon
Public Member Functions
thor::Animator Class Reference

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

void thor::Animator::AddAnimation ( const std::string &  name,
Animation::Ptr  animation,
sf::Time  duration 
)

Registers an animation with a given name.

Parameters:
nameString to assign to the animation (may not be registered yet).
animationAnimation to add to the animator.
durationDuration of the animation.
void thor::Animator::Animate ( sf::Sprite &  target) const

Applies the stored animations to a sf::Sprite.

Parameters:
targetSprite 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.
void thor::Animator::PlayAnimation ( const std::string &  name,
bool  loop = false 
)

Plays the animation with the given name.

Parameters:
nameName of the animation to play (std::string). An animation with this name must have been added before.
loopTrue if the animation is played repeatedly.
void thor::Animator::SetDefaultAnimation ( Animation::Ptr  animation,
sf::Time  duration 
)

Sets an animation that is active when all others are stopped.

Parameters:
animationDefault 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.
durationDuration 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.

void thor::Animator::Update ( sf::Time  dt)

Updates the animator's progress. You should call this method each frame.

Parameters:
dtFrame time.

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