class MASKING_DLL_DECLSPEC Animator

Provides basic animation functionality for the GUI.

Public Methods

[more]bool Animating()
Returns true if an animation is in progress
[more]bool Update()
Updates animation variables.
[more]void Reset()
Resets the animation variables and destroys the background
[more]void Create(Bitmap &bmp, int length)
Sets up a new animation.
[more]Bitmap& GetBuffer()
Returns the buffer onto which you can draw whatever is to be animated
[more]virtual void Draw(Bitmap &canvas, int type)
Draws one frame of animation.

Public Members

[more]enum AnimationType
Animation types.

Protected Fields

[more]Bitmap buffer
The buffer that is actually being animated.
[more]Bitmap back
The background of the animated buffer.
[more]int frames
Total number of frames in the animation
[more]int progress
The current frame of animation


Documentation

Provides basic animation functionality for the GUI. There are currently 26 different available animation not all of which are really that impressive or usefull. Animatiions provided by this class are mostly used as transition effects for certain widget, for example for buttons changing from one state to another and so on.
oenum AnimationType
Animation types. These are all currently available animations. The names are quite self explanatory in most cases I think.
            NONE
            BLEND
            SLIDE_DOWN
            SLIDE_UP
            SLIDE_LEFT
            SLIDE_RIGHT
            ROLL_DOWN
            ROLL_UP
            ROLL_LEFT
            ROLL_RIGHT
            BLINDS_DOWN
            BLINDS_UP
            BLINDS_LEFT
            BLINDS_RIGHT
            OPEN_VERTICAL
            OPEN_HORIZONTAL
            OPEN_FROM_CENTRE
            ROLL_OPEN_VERTICAL
            ROLL_OPEN_HORIZONTAL
            ROLL_OPEN_FROM_CENTRE
            CLOSE_VERTICAL
            CLOSE_HORIZONTAL
            CLOSE_TO_CENTRE
            ROLL_CLOSE_VERTICAL
            ROLL_CLOSE_HORIZONTAL
            ROLL_CLOSE_TO_CENTRE
            ROLL_CLOSE_TO_CENTRE2

oBitmap buffer
The buffer that is actually being animated. The user should draw onto this buffer, then call the Draw() function to draw to the canvas.

oBitmap back
The background of the animated buffer. Most animations need to have this bitmap along with the animated buffer so they can interpolate each frame between them.

oint frames
Total number of frames in the animation

oint progress
The current frame of animation

obool Animating()
Returns true if an animation is in progress

obool Update()
Updates animation variables. Returns true if the animation is still in progress and false if it has finished.

ovoid Reset()
Resets the animation variables and destroys the background

ovoid Create(Bitmap &bmp, int length)
Sets up a new animation. The parameters passed are the bitmap that is to be animated and the length of the animation in miliseconds.

oBitmap& GetBuffer()
Returns the buffer onto which you can draw whatever is to be animated

ovirtual void Draw(Bitmap &canvas, int type)
Draws one frame of animation. Parameters are the canvas onto which the animation should be drawn and the type of animation that is to be used. See above for a list of available animation types.

Here's a small example:

       make a screen bitmap and clear it with lightgray
      Bitmap screen;
      screen = ::screen;
      screen.Clear(Color::lightgray);

make a backbuffer for double buffering and clear it Bitmap buffer; buffer.Create(SCREEN_W, SCREEN_H); buffer.Clear(Color::lightgray);

make a canvas for a nice little "window" Bitmap canvas; canvas.CreateSubBitmap(buffer, 100, 20, 120, 60);

now make an animator Animator anim; anim.Create(canvas, 500); first create an animated buffer anim.GetBuffer().Clear(Color::red); draw to the animated buffer

now do the main loop; this should normally be controled by a timer do { update the animator anim.Update();

draw the next frame of animation anim.Draw(canvas, Animator::BLEND);

do the double buffering bit buffer.Blit(screen, 0, 0, 0, 0, buffer.w(), buffer.h());

wait for a while rest(20); } while (anim.Animating());


This class has no child classes.

Alphabetic index Hierarchy of classes


Back to front page   |   page generated with DOC++