Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QCanvasSprite class provides an animated canvas item on a QCanvas. More...
#include <qcanvas.h>
Inherits QCanvasItem.
A canvas sprite is an object which can contain any number of images (referred to as frames), only one of which is current, i.e. displayed, at any one time. The images can be passed in the constructor or set or changed later with setSequence(). If you subclass QCanvasSprite you can change the frame that is displayed periodically, e.g. whenever QCanvasItem::advance(1) is called to create the effect of animation.
The current frame can be set with setFrame() or with move(). The number of frames available is given by frameCount(). The bounding rectangle of the current frame is returned by boundingRect().
The current frame's image can be retrieved with image(); use imageAdvanced() to retrieve the image for the frame that will be shown after advance(1) is called. Use the image() overload passing it an integer index to retrieve a particular image from the list of frames.
Use width() and height() to retrieve the dimensions of the current frame.
Use leftEdge() and rightEdge() to retrieve the current frame's left-hand and right-hand x-coordinates respectively. Use bottomEdge() and topEdge() to retrieve the current frame's bottom and top y-coordinates respectively. These functions have an overload which will accept an integer frame number to retrieve the coordinates of a particular frame.
QCanvasSprite draws very quickly, at the expense of memory.
The current frame's image can be drawn on a painter with draw().
Like any other canvas item, canvas sprites can be moved with move() which sets the x and y coordinates and the frame number, as well as with QCanvasItem::move() and QCanvasItem::moveBy(), or by setting coordinates with QCanvasItem::setX(), QCanvasItem::setY() and QCanvasItem::setZ().
See also Graphics Classes and Image Processing Classes.
This enum is used to identify the different types of frame animation of QCanvasSprite.
The sprite in initially positioned at (0,0) on canvas, using frame 0.
The phase is 0 or 1: see QCanvas::animate() for details.
See also QCanvasItem::advance() and setVelocity().
Example: canvas/canvas.cpp.
Reimplemented from QCanvasItem.
See also leftEdge(), rightEdge() and topEdge().
Returns what the y-coordinate of the top edge of the sprite would be if the sprite (actually its hotspot) were moved to y-position ny.
See also leftEdge(), rightEdge() and topEdge().
Reimplemented from QCanvasItem.
Reimplemented from QCanvasItem.
Returns the index of the current animation frame in the QCanvasSprite's QCanvasPixmapArray.
See also setFrame() and move().
Returns the number of frames in the QCanvasSprite's QCanvasPixmapArray.
See also frame().
Returns the current frame's image.
See also frame() and setFrame().
Returns the image for frame f. Does not do any bounds checking on f.
See also rightEdge(), bottomEdge() and topEdge().
Returns what the x-coordinate of the left edge of the sprite would be if the sprite (actually its hotspot) were moved to x-position nx.
See also rightEdge(), bottomEdge() and topEdge().
Set the position of the sprite to nx, ny and the current frame to nf. nf will be ignored if it is larger than frameCount() or smaller than 0.
See also leftEdge(), bottomEdge() and topEdge().
Returns what the x-coordinate of the right edge of the sprite would be if the sprite (actually its hotspot) were moved to x-position nx.
See also leftEdge(), bottomEdge() and topEdge().
See also QCanvasItem::rtti().
Example: canvas/canvas.cpp.
Reimplemented from QCanvasItem.
For type == Cycle, the frames will increase by step at each advance, modulo the frameCount().
For type == Oscillate, the frames will increase by step at each advance, up to the frameCount(), then decrease by step back to 0, etc.
The state parameter is for internal use.
If the current frame() is larger than the number of images in a, the current frame will be reset to 0.
See also leftEdge(), rightEdge() and bottomEdge().
Returns what the y-coordinate of the top edge of the sprite would be if the sprite (actually its hotspot) were moved to y-position ny.
See also leftEdge(), rightEdge() and bottomEdge().
See also frame().
This file is part of the Qt toolkit. Copyright © 1995-2002 Trolltech. All Rights Reserved.
Copyright © 2002 Trolltech | Trademarks | Qt version 3.0.5
|