ComponentAnimator Class Reference

Inheritance diagram for ComponentAnimator:

Timer List of all members.

Detailed Description

Animates a set of components, moving it to a new position.

To use this, create a ComponentAnimator, and use its animateComponent() method to tell it to move components to destination positions. Any number of components can be animated by one ComponentAnimator object (if you've got a lot of components to move, it's much more efficient to share a single animator than to have many animators running at once).

You'll need to make sure the animator object isn't deleted before it finishes moving the components.


Public Member Functions

 ComponentAnimator ()
 Creates a ComponentAnimator.
 ~ComponentAnimator ()
 Destructor.
void animateComponent (Component *const component, const Rectangle &finalPosition, const int millisecondsToSpendMoving, const double startSpeed=1.0, const double endSpeed=1.0)
 Starts a component moving from its current position to a specified position.
void cancelAnimation (Component *const component, const bool moveComponentToItsFinalPosition)
 Stops a component if it's currently being animated.
void cancelAllAnimations (const bool moveComponentsToTheirFinalPositions)
 Clears all of the active animations.
const Rectangle getComponentDestination (Component *const component)
 Returns the destination position for a component.


Constructor & Destructor Documentation

ComponentAnimator::ComponentAnimator  ) 
 

Creates a ComponentAnimator.

ComponentAnimator::~ComponentAnimator  ) 
 

Destructor.


Member Function Documentation

void ComponentAnimator::animateComponent Component *const   component,
const Rectangle finalPosition,
const int  millisecondsToSpendMoving,
const double  startSpeed = 1.0,
const double  endSpeed = 1.0
 

Starts a component moving from its current position to a specified position.

If the component is already in the middle of an animation, that will be abandoned, and a new animation will begin, moving the component from its current location.

The start and end speed parameters let you apply some acceleration to the component's movement.

Parameters:
component the component to move
finalPosition the destination position and size to move it to
millisecondsToSpendMoving how long, in milliseconds, it should take to arrive at its destination
startSpeed a value to indicate the relative start speed of the animation. If this is 0, the component will start by accelerating from rest; higher values mean that it will have an initial speed greater than zero. If the value if greater than 1, it will decelerate towards the middle of its journey. To move the component at a constant rate for its entire animation, set both the start and end speeds to 1.0
endSpeed a relative speed at which the component should be moving when the animation finishes. If this is 0, the component will decelerate to a standstill at its final position; higher values mean the component will still be moving when it stops. To move the component at a constant rate for its entire animation, set both the start and end speeds to 1.0

void ComponentAnimator::cancelAnimation Component *const   component,
const bool  moveComponentToItsFinalPosition
 

Stops a component if it's currently being animated.

If moveComponentToItsFinalPosition is true, then the component will be immediately moved to its destination position and size. If false, it will be left in whatever location it currently occupies.

void ComponentAnimator::cancelAllAnimations const bool  moveComponentsToTheirFinalPositions  ) 
 

Clears all of the active animations.

If moveComponentsToTheirFinalPositions is true, all the components will be immediately set to their final positions. If false, they will be left in whatever locations they currently occupy.

const Rectangle ComponentAnimator::getComponentDestination Component *const   component  ) 
 

Returns the destination position for a component.

If the component is being animated, this will return the target position that was specified when animateComponent() was called.

If the specified component isn't currently being animated, this method will just return its current position.


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