QCanvasSprite(3qt)

NAME
QCanvasSprite - Animated moving pixmap on a

#include <qcanvas.h>

Inherits QCanvasItem.

  Public Members
QCanvasSprite ( QCanvasPixmapArray * array, QCanvas * canvas )
void setSequence ( QCanvasPixmapArray * seq )
virtual ~QCanvasSprite ()
virtual void move ( double x, double y, int frame )
void setFrame ( int )
int frame () const
int frameCount () const
virtual int rtti () const
virtual QRect boundingRect () const

  Protected Members
virtual void draw ( QPainter & painter )
int width () const
int height () const
int absX () const
int absY () const
int absX2 () const
int absY2 () const
int absX ( int nx ) const
int absY ( int ny ) const
int absX2 ( int nx ) const
int absY2 ( int ny ) const
QCanvasPixmap* image () const
virtual QCanvasPixmap* imageAdvanced () const
QCanvasPixmap* image ( int f ) const

DESCRIPTION
The QCanvasSprite class provides an animated moving pixmap on a QCanvas.

A "sprite" is an image object that moves around independently of foreground and background. On a QCanvas, everything moves around independently of the foreground and background, so a QCanvasSprite is just a image whose API makes it simpler to use animation and a hot spot.

QCanvasSprite draws very fast, at the cost of some memory.

MEMBER FUNCTION DOCUMENTATION

QCanvasSprite::QCanvasSprite ( QCanvasPixmapArray * a, QCanvas * canvas )
Constructs a QCanvasSprite which uses images from the given array.

The sprite in initially at (0,0) on canvas, using frame 0.

QCanvasSprite::~QCanvasSprite () [virtual]
Destruct the sprite. It is removed from its QCanvas in this process.

int QCanvasSprite::absX () const [protected]
The absolute horizontal position of the sprite. This is the pixel position of the left edge of the image, as it takes into account the offset.

int QCanvasSprite::absX ( int nx ) const [protected]
The absolute horizontal position of the sprite, if it was moved to nx.

int QCanvasSprite::absX2 () const [protected]
The right edge of the sprite image.

See also absX().

int QCanvasSprite::absX2 ( int nx ) const [protected]
The right edge of the sprite image, if the sprite was moved to nx.

See also absX().

int QCanvasSprite::absY () const [protected]
The absolute vertical position of the sprite. This is the pixel position of the top edge of the image, as it takes into account the offset.

int QCanvasSprite::absY ( int ny ) const [protected]
The absolute vertical position of the sprite, if it was moved to ny.

int QCanvasSprite::absY2 () const [protected]
The bottom edge of the sprite image.

See also absY().

int QCanvasSprite::absY2 ( int ny ) const [protected]
The bottom edge of the sprite image, if the sprite was moved to ny.

See also absY().

QRect QCanvasSprite::boundingRect () const [virtual]
Returns the bounding rectangle of pixels covered by the sprite. This assumes that the images are tightly cropped (ie. do not have transparent pixels all along a side).

Reimplemented from QCanvasItem.

bool QCanvasSprite::collidesWith ( const QCanvasItem * i ) const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QCanvasItem.

void QCanvasSprite::draw ( QPainter & painter ) [virtual protected]
Draws the current image of the sprite at its current position, as given by image() and x(), y().

Reimplemented from QCanvasItem.

int QCanvasSprite::frame () const
Returns the index into the QCanvasSprite's QCanvasPixmapArray of the current animation frame.

See also setFrame() and move(double,double,int).

int QCanvasSprite::frameCount () const
Returns the number of frames in the QCanvasSprite's QCanvasPixmapArray.

int QCanvasSprite::height () const [protected]
The height of the sprite, in its current image.

See also frame().

QCanvasPixmap* QCanvasSprite::image () const [protected]
Returns the current image frame.

See also frame() and setFrame().

QCanvasPixmap* QCanvasSprite::image ( int f ) const [protected]
Returns image frame f.

QCanvasPixmap* QCanvasSprite::imageAdvanced () const [virtual protected]
The image the sprite will have after advance(1) is called. Be default this is the same as image().

void QCanvasSprite::move ( double nx, double ny, int nf ) [virtual]
Set both the position and the frame of the sprite.

void QCanvasSprite::move ( double x, double y )
Reimplemented for internal reasons; the API is not affected.

int QCanvasSprite::rtti () const [virtual]
Returns 1.

void QCanvasSprite::setFrame ( int f )
Sets the animation frame used for displaying the sprite to f, an index into the QCanvasSprite's QCanvasPixmapArray.

See also frame() and move(double,double,int).

void QCanvasSprite::setSequence ( QCanvasPixmapArray * a )
Set the array of images used for displaying the sprite. Note that the array should have enough images for the sprites current frame() to be valid.

int QCanvasSprite::width () const [protected]
The width of the sprite, in its current image.

See also frame().

SEE ALSO
http://doc.trolltech.com/qcanvassprite.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qcanvassprite.3qt) and the Qt version (2.3.7).