'\" t .TH TQCanvasSprite 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*- .\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the .\" license file included in the distribution for a complete license .\" statement. .\" .ad l .nh .SH NAME TQCanvasSprite \- Animated canvas item on a TQCanvas .SH SYNOPSIS \fC#include \fR .PP Inherits TQCanvasItem. .PP .SS "Public Members" .in +1c .ti -1c .BI "\fBTQCanvasSprite\fR ( TQCanvasPixmapArray * a, TQCanvas * canvas )" .br .ti -1c .BI "void \fBsetSequence\fR ( TQCanvasPixmapArray * a )" .br .ti -1c .BI "virtual \fB~TQCanvasSprite\fR ()" .br .ti -1c .BI "virtual void \fBmove\fR ( double nx, double ny, int nf )" .br .ti -1c .BI "void \fBsetFrame\fR ( int f )" .br .ti -1c .BI "enum \fBFrameAnimationType\fR { Cycle, Oscillate }" .br .ti -1c .BI "virtual void \fBsetFrameAnimation\fR ( FrameAnimationType type = Cycle, int step = 1, int state = 0 )" .br .ti -1c .BI "int \fBframe\fR () const" .br .ti -1c .BI "int \fBframeCount\fR () const" .br .ti -1c .BI "virtual int \fBrtti\fR () const" .br .ti -1c .BI "virtual TQRect \fBboundingRect\fR () const" .br .ti -1c .BI "int \fBwidth\fR () const" .br .ti -1c .BI "int \fBheight\fR () const" .br .ti -1c .BI "int \fBleftEdge\fR () const" .br .ti -1c .BI "int \fBtopEdge\fR () const" .br .ti -1c .BI "int \fBrightEdge\fR () const" .br .ti -1c .BI "int \fBbottomEdge\fR () const" .br .ti -1c .BI "int \fBleftEdge\fR ( int nx ) const" .br .ti -1c .BI "int \fBtopEdge\fR ( int ny ) const" .br .ti -1c .BI "int \fBrightEdge\fR ( int nx ) const" .br .ti -1c .BI "int \fBbottomEdge\fR ( int ny ) const" .br .ti -1c .BI "TQCanvasPixmap * \fBimage\fR () const" .br .ti -1c .BI "virtual TQCanvasPixmap * \fBimageAdvanced\fR () const" .br .ti -1c .BI "TQCanvasPixmap * \fBimage\fR ( int f ) const" .br .ti -1c .BI "virtual void \fBadvance\fR ( int phase )" .br .ti -1c .BI "virtual void \fBdraw\fR ( TQPainter & painter )" .br .in -1c .SH DESCRIPTION The TQCanvasSprite class provides an animated canvas item on a TQCanvas. .PP 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. .PP 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(). .PP 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. .PP Use width() and height() to retrieve the dimensions of the current frame. .PP 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. .PP TQCanvasSprite draws very quickly, at the expense of memory. .PP The current frame's image can be drawn on a painter with draw(). .PP 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(). .PP See also Graphics Classes and Image Processing Classes. .SS "Member Type Documentation" .SH "TQCanvasSprite::FrameAnimationType" This enum is used to identify the different types of frame animation offered by TQCanvasSprite. .TP \fCTQCanvasSprite::Cycle\fR - at each advance the frame number will be incremented by 1 (modulo the frame count). .TP \fCTQCanvasSprite::Oscillate\fR - at each advance the frame number will be incremented by 1 up to the frame count then decremented to by 1 to 0, repeating this sequence forever. .SH MEMBER FUNCTION DOCUMENTATION .SH "TQCanvasSprite::TQCanvasSprite ( TQCanvasPixmapArray * a, TQCanvas * canvas )" Constructs a TQCanvasSprite which uses images from the TQCanvasPixmapArray \fIa\fR. .PP The sprite in initially positioned at (0, 0) on \fIcanvas\fR, using frame 0. .SH "TQCanvasSprite::~TQCanvasSprite ()\fC [virtual]\fR" Destroys the sprite and removes it from the canvas. Does \fInot\fR delete the images. .SH "void TQCanvasSprite::advance ( int phase )\fC [virtual]\fR" Extends the default TQCanvasItem implementation to provide the functionality of setFrameAnimation(). .PP The \fIphase\fR is 0 or 1: see TQCanvasItem::advance() for details. .PP See also TQCanvasItem::advance() and setVelocity(). .PP Example: canvas/canvas.cpp. .PP Reimplemented from TQCanvasItem. .SH "int TQCanvasSprite::bottomEdge () const" Returns the y-coordinate of the current bottom edge of the sprite. (This may change as the sprite animates since different frames may have different bottom edges.) .PP See also leftEdge(), rightEdge(), and topEdge(). .SH "int TQCanvasSprite::bottomEdge ( int ny ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP 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 \fIny\fR. .PP See also leftEdge(), rightEdge(), and topEdge(). .SH "TQRect TQCanvasSprite::boundingRect () const\fC [virtual]\fR" Returns the bounding rectangle for the image in the sprite's current frame. This assumes that the images are tightly cropped (i.e. do not have transparent pixels all along a side). .PP Reimplemented from TQCanvasItem. .SH "void TQCanvasSprite::draw ( TQPainter & painter )\fC [virtual]\fR" Draws the current frame's image at the sprite's current position on painter \fIpainter\fR. .PP Reimplemented from TQCanvasItem. .SH "int TQCanvasSprite::frame () const" Returns the index of the current animation frame in the TQCanvasSprite's TQCanvasPixmapArray. .PP See also setFrame() and move(). .SH "int TQCanvasSprite::frameCount () const" Returns the number of frames in the TQCanvasSprite's TQCanvasPixmapArray. .SH "int TQCanvasSprite::height () const" The height of the sprite for the current frame's image. .PP See also frame(). .SH "TQCanvasPixmap * TQCanvasSprite::image () const" Returns the current frame's image. .PP See also frame() and setFrame(). .SH "TQCanvasPixmap * TQCanvasSprite::image ( int f ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP Returns the image for frame \fIf\fR. Does not do any bounds checking on \fIf\fR. .SH "TQCanvasPixmap * TQCanvasSprite::imageAdvanced () const\fC [virtual]\fR" Returns the image the sprite \fIwill\fR have after advance(1) is called. By default this is the same as image(). .SH "int TQCanvasSprite::leftEdge () const" Returns the x-coordinate of the current left edge of the sprite. (This may change as the sprite animates since different frames may have different left edges.) .PP See also rightEdge(), bottomEdge(), and topEdge(). .SH "int TQCanvasSprite::leftEdge ( int nx ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP 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 \fInx\fR. .PP See also rightEdge(), bottomEdge(), and topEdge(). .SH "void TQCanvasSprite::move ( double nx, double ny, int nf )\fC [virtual]\fR" Set the position of the sprite to \fInx\fR, \fIny\fR and the current frame to \fInf\fR. \fInf\fR will be ignored if it is larger than frameCount() or smaller than 0. .SH "int TQCanvasSprite::rightEdge () const" Returns the x-coordinate of the current right edge of the sprite. (This may change as the sprite animates since different frames may have different right edges.) .PP See also leftEdge(), bottomEdge(), and topEdge(). .SH "int TQCanvasSprite::rightEdge ( int nx ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP 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 \fInx\fR. .PP See also leftEdge(), bottomEdge(), and topEdge(). .SH "int TQCanvasSprite::rtti () const\fC [virtual]\fR" Returns 1 (TQCanvasItem::Rtti_Sprite). .PP See also TQCanvasItem::rtti(). .PP Example: canvas/canvas.cpp. .PP Reimplemented from TQCanvasItem. .SH "void TQCanvasSprite::setFrame ( int f )" Sets the animation frame used for displaying the sprite to \fIf\fR, an index into the TQCanvasSprite's TQCanvasPixmapArray. The call will be ignored if \fIf\fR is larger than frameCount() or smaller than 0. .PP See also frame() and move(). .SH "void TQCanvasSprite::setFrameAnimation ( FrameAnimationType type = Cycle, int step = 1, int state = 0 )\fC [virtual]\fR" Sets the animation characteristics for the sprite. .PP For \fItype\fR == Cycle, the frames will increase by \fIstep\fR at each advance, modulo the frameCount(). .PP For \fItype\fR == Oscillate, the frames will increase by \fIstep\fR at each advance, up to the frameCount(), then decrease by \fIstep\fR back to 0, repeating forever. .PP The \fIstate\fR parameter is for internal use. .SH "void TQCanvasSprite::setSequence ( TQCanvasPixmapArray * a )" Set the array of images used for displaying the sprite to the TQCanvasPixmapArray \fIa\fR. .PP If the current frame() is larger than the number of images in \fIa\fR, the current frame will be reset to 0. .SH "int TQCanvasSprite::topEdge () const" Returns the y-coordinate of the top edge of the sprite. (This may change as the sprite animates since different frames may have different top edges.) .PP See also leftEdge(), rightEdge(), and bottomEdge(). .SH "int TQCanvasSprite::topEdge ( int ny ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP 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 \fIny\fR. .PP See also leftEdge(), rightEdge(), and bottomEdge(). .SH "int TQCanvasSprite::width () const" The width of the sprite for the current frame's image. .PP See also frame(). .SH "SEE ALSO" .BR http://doc.trolltech.com/tqcanvassprite.html .BR http://www.trolltech.com/faq/tech.html .SH COPYRIGHT Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. .SH AUTHOR Generated automatically from the source code. .SH BUGS If you find a bug in Qt, please report it as described in .BR http://doc.trolltech.com/bughowto.html . Good bug reports help us to help you. Thank you. .P The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. .P If you find errors in this manual page, please report them to .BR qt-bugs@trolltech.com . Please include the name of the manual page (tqcanvassprite.3qt) and the Qt version (3.3.8).