HomeHome

ClassesAnnotated - TreeFunctionsHomeStructure

QCanvasSprite Class Reference
[ canvas module ]


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

#include <qcanvas.h>

Inherits QCanvasItem.

List of all member functions.

Public Members

Protected Members


Detailed 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().

QCanvasPixmapQCanvasSprite::image () const [protected]

Returns the current image frame.

See also frame() and setFrame().

QCanvasPixmapQCanvasSprite::image ( int f ) const [protected]

Returns image frame f.

QCanvasPixmapQCanvasSprite::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().


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.


Copyright © 2000 TrolltechTrademarks
Qt version 2.2.1