Product Home Class IndexDownload

CK_Animation

CK_Bitmap
   |
   +----CK_Animation

The CK_Animation class represents a displayable animation running at a specified frame rate, and it's state can be either started or stopped.

A CK_Animation is a CK_Bitmap. This allows it to be used as a property in any CK_Component that uses a bitmap property.

A CK_Animation object contains a reference to a CK_AnimatedBitmap. Many CK_Animation objects can reference the same CK_AnimatedBitmap. The CK_AnimatedBitmap is simply a storage container for the image data. The CK_Animation contains the frame rate, as well as the current state: whether the animation is stopped or running, and the index of the frame that is currently visible.

Depending on how the CK_Animation is created, it may or may not have ownership of the CK_AnimatedBitmap. The programmer can decide whether a given CK_Animation owns its CK_AnimatedBitmap. Objects that own other objects will delete the owned objects when they themselves are deleted.


Factory Methods

createFromFile
Creates a CK_Animation from a .pcx or .bmp file containing the frames of the animation.

Public Methods

CK_Animation
Constructs the animation from a CK_AnimatedBitmap.
getCurrentFrame
Returns the index of the frame that is currently shown.
getFrameRate
Gets the animation's frame rate. (number of frames per second)
getNumFrames
Returns the number of frames in the animation.
getSubject
Returns the CK_Subject contained within CK_Animation.
isStopped
Returns TRUE if the animation is not running.
manualAdvanceFrame
Advances the current frame by one.
manualBackupFrame
Backs up to the previous frame.
manualSetFrame
Sets the current frame to the specified frame.
setFrameRate
Sets the animation's frame rate (number of frames per second).
startAnimation
Causes the animation to start.
stopAnimation
Causes the animation to stop.

Inherited Methods

draw
Draws the bitmap to the Chilkat engine's render surface.
drawScaled
Draws a stretched or shrunken bitmap to the render surface.
drawTiled
Fills the render surface, or a portion of the render surface, by tiling the bitmap.
getHeight
Returns the height in pixels of the bitmap.
getNumPalettes
Returns the number of palettes contained in the bitmap.Only 8 bit-per-pixel bitmaps have palettes.
getWidth
Returns the width in pixels of the bitmap.
isPaletteBitmap
Returns TRUE if the bitmap is 8 bits-per-pixel.
isTransparent
Returns TRUE if the bitmap has transparency.

Creates a CK_Animation from a graphics file (.pcx or .bmp) where the frames of the animation are organized in rows and columns. The figure below shows one possible layout of frames for an animation with 10 frames.

Return Value
Returns a pointer to the CK_Animation object created.

Parameters

fileName
The file (.pcx or .bmp) containing a grid of frames.
nColumns
The number of columns in the grid.
frameWidth
The width in pixels of each frame.
frameHeight
The height in pixels of each frame.
numFrames
The total number of frames in the animation. This does not need to be evenly divisible by the number of columns, as demonstrated in the example above.

Remarks

This factory method internally creates a CK_AnimatedImage that is used to create the CK_Animation. The animated image is owned by the animation, and is deleted when the animation is deleted.

This is the most common way to create a CK_Animation. The application first creates a CK_AnimatedBitmap, and then many CK_Animation objects can be created that reference the animated bitmap.

Parameters

anim
The animated bitmap that contains the image data for each frame in the animation.
takeOwnership
If TRUE, the CK_Animation owns the animated bitmap. This causes the animated bitmap to be deleted when the CK_Animation is deleted.

Parameters

frameIndex
The current frame will be set to this index.

Parameters

framesPerSecond
The speed at which the animation runs.