You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
264 lines
11 KiB
264 lines
11 KiB
13 years ago
|
'\" t
|
||
|
.TH QCanvasSprite 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
|
||
|
QCanvasSprite \- Animated canvas item on a QCanvas
|
||
|
.SH SYNOPSIS
|
||
|
\fC#include <qcanvas.h>\fR
|
||
|
.PP
|
||
|
Inherits QCanvasItem.
|
||
|
.PP
|
||
|
.SS "Public Members"
|
||
|
.in +1c
|
||
|
.ti -1c
|
||
|
.BI "\fBQCanvasSprite\fR ( QCanvasPixmapArray * a, QCanvas * canvas )"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "void \fBsetSequence\fR ( QCanvasPixmapArray * a )"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "virtual \fB~QCanvasSprite\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 QRect \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 "QCanvasPixmap * \fBimage\fR () const"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "virtual QCanvasPixmap * \fBimageAdvanced\fR () const"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "QCanvasPixmap * \fBimage\fR ( int f ) const"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "virtual void \fBadvance\fR ( int phase )"
|
||
|
.br
|
||
|
.ti -1c
|
||
|
.BI "virtual void \fBdraw\fR ( QPainter & painter )"
|
||
|
.br
|
||
|
.in -1c
|
||
|
.SH DESCRIPTION
|
||
|
The QCanvasSprite class provides an animated canvas item on a QCanvas.
|
||
|
.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 QCanvasSprite you can change the frame that is displayed periodically, e.g. whenever QCanvasItem::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
|
||
|
QCanvasSprite draws very tquickly, 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 QCanvasItem::move() and QCanvasItem::moveBy(), or by setting coordinates with QCanvasItem::setX(), QCanvasItem::setY() and QCanvasItem::setZ().
|
||
|
.PP
|
||
|
See also Graphics Classes and Image Processing Classes.
|
||
|
.SS "Member Type Documentation"
|
||
|
.SH "QCanvasSprite::FrameAnimationType"
|
||
|
This enum is used to identify the different types of frame animation offered by QCanvasSprite.
|
||
|
.TP
|
||
|
\fCQCanvasSprite::Cycle\fR - at each advance the frame number will be incremented by 1 (modulo the frame count).
|
||
|
.TP
|
||
|
\fCQCanvasSprite::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 "QCanvasSprite::QCanvasSprite ( QCanvasPixmapArray * a, QCanvas * canvas )"
|
||
|
Constructs a QCanvasSprite which uses images from the QCanvasPixmapArray \fIa\fR.
|
||
|
.PP
|
||
|
The sprite in initially positioned at (0, 0) on \fIcanvas\fR, using frame 0.
|
||
|
.SH "QCanvasSprite::~QCanvasSprite ()\fC [virtual]\fR"
|
||
|
Destroys the sprite and removes it from the canvas. Does \fInot\fR delete the images.
|
||
|
.SH "void QCanvasSprite::advance ( int phase )\fC [virtual]\fR"
|
||
|
Extends the default QCanvasItem implementation to provide the functionality of setFrameAnimation().
|
||
|
.PP
|
||
|
The \fIphase\fR is 0 or 1: see QCanvasItem::advance() for details.
|
||
|
.PP
|
||
|
See also QCanvasItem::advance() and setVelocity().
|
||
|
.PP
|
||
|
Example: canvas/canvas.cpp.
|
||
|
.PP
|
||
|
Reimplemented from QCanvasItem.
|
||
|
.SH "int QCanvasSprite::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 QCanvasSprite::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 "QRect QCanvasSprite::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 QCanvasItem.
|
||
|
.SH "void QCanvasSprite::draw ( QPainter & painter )\fC [virtual]\fR"
|
||
|
Draws the current frame's image at the sprite's current position on painter \fIpainter\fR.
|
||
|
.PP
|
||
|
Reimplemented from QCanvasItem.
|
||
|
.SH "int QCanvasSprite::frame () const"
|
||
|
Returns the index of the current animation frame in the QCanvasSprite's QCanvasPixmapArray.
|
||
|
.PP
|
||
|
See also setFrame() and move().
|
||
|
.SH "int QCanvasSprite::frameCount () const"
|
||
|
Returns the number of frames in the QCanvasSprite's QCanvasPixmapArray.
|
||
|
.SH "int QCanvasSprite::height () const"
|
||
|
The height of the sprite for the current frame's image.
|
||
|
.PP
|
||
|
See also frame().
|
||
|
.SH "QCanvasPixmap * QCanvasSprite::image () const"
|
||
|
Returns the current frame's image.
|
||
|
.PP
|
||
|
See also frame() and setFrame().
|
||
|
.SH "QCanvasPixmap * QCanvasSprite::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 "QCanvasPixmap * QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::rtti () const\fC [virtual]\fR"
|
||
|
Returns 1 (QCanvasItem::Rtti_Sprite).
|
||
|
.PP
|
||
|
See also QCanvasItem::rtti().
|
||
|
.PP
|
||
|
Example: canvas/canvas.cpp.
|
||
|
.PP
|
||
|
Reimplemented from QCanvasItem.
|
||
|
.SH "void QCanvasSprite::setFrame ( int f )"
|
||
|
Sets the animation frame used for displaying the sprite to \fIf\fR, an index into the QCanvasSprite's QCanvasPixmapArray. The call will be ignored if \fIf\fR is larger than frameCount() or smaller than 0.
|
||
|
.PP
|
||
|
See also frame() and move().
|
||
|
.SH "void QCanvasSprite::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 QCanvasSprite::setSequence ( QCanvasPixmapArray * a )"
|
||
|
Set the array of images used for displaying the sprite to the QCanvasPixmapArray \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 QCanvasSprite::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 QCanvasSprite::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 QCanvasSprite::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/qcanvassprite.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 Qt documentation is provided in HTML format; it is
|
||
|
located at $QTDIR/doc/html and can be read using Qt 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 (qcanvassprite.3qt) and the Qt
|
||
|
version (3.3.8).
|