Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The TQCanvasSprite class provides an animated canvas item on a TQCanvas. More...
#include <ntqcanvas.h>
Inherits TQCanvasItem.
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 TQCanvasSprite you can change the frame that is displayed periodically, e.g. whenever TQCanvasItem::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.
TQCanvasSprite 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 TQCanvasItem::move() and TQCanvasItem::moveBy(), or by setting coordinates with TQCanvasItem::setX(), TQCanvasItem::setY() and TQCanvasItem::setZ().
See also Graphics Classes and Image Processing Classes.
This enum is used to identify the different types of frame animation offered by TQCanvasSprite.
The sprite in initially positioned at (0, 0) on canvas, using frame 0.
The phase is 0 or 1: see TQCanvasItem::advance() for details.
See also TQCanvasItem::advance() and setVelocity().
Example: canvas/canvas.cpp.
Reimplemented from TQCanvasItem.
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 TQCanvasItem.
Reimplemented from TQCanvasItem.
Returns the index of the current animation frame in the TQCanvasSprite's TQCanvasPixmapArray.
See also setFrame() and move().
Returns the number of frames in the TQCanvasSprite's TQCanvasPixmapArray.
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 TQCanvasItem::rtti().
Example: canvas/canvas.cpp.
Reimplemented from TQCanvasItem.
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, repeating forever.
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 TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | TQt 3.3.8
|