📄 qcanvassprite.3qt
字号:
'\" t.TH QCanvasSprite 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQCanvasSprite \- Animated canvas item on a QCanvas.PP\fC#include <qcanvas.h>\fR.PPInherits 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 DESCRIPTIONThe QCanvasSprite class provides an animated canvas item on a QCanvas..PPA canvas sprite is an object which contains any number of images (referred to as frames), only one of which is current, e.g. 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..PPThe 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()..PPThe 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..PPUse width() and height() to retrieve the dimensions of the current frame..PPUse 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..PPQCanvasSprite draws very quickly, at the cost of some memory..PPThe current frame's image can be drawn on a painter with draw()..PPLike 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()..PPSee 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 of 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..PPThe 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()..PPThe \fIphase\fR is 0 or 1: see QCanvas::animate() for details..PPSee also QCanvasItem::advance() and setVelocity()..PPReimplemented 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.).PPSee 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..PPReturns 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..PPSee also leftEdge(), rightEdge() and topEdge()..SH "QRect QCanvasSprite::boundingRect () const\fC [virtual]\fR"Returns the bounding rectangle for the image in sprite's current frame. This assumes that the images are tightly cropped (ie. do not have transparent pixels all along a side)..PPReimplemented 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..PPReimplemented from QCanvasItem..SH "int QCanvasSprite::frame () const"Returns the index of the current animation frame in the QCanvasSprite's QCanvasPixmapArray..PPSee 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..PPSee also frame()..SH "QCanvasPixmap * QCanvasSprite::image () const"Returns the current frame's image..PPSee 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..PPReturns 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.).PPSee 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..PPReturns 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..PPSee 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.).PPSee 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..PPReturns 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..PPSee also leftEdge(), bottomEdge() and topEdge()..SH "int QCanvasSprite::rtti () const\fC [virtual]\fR"Returns 1 (QCanvasItem::Rtti_Sprite)..PPSee also QCanvasItem::rtti()..PPReimplemented 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..PPSee 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..PPFor \fItype\fR == Cycle, the frames will increase by \fIstep\fR at each advance, modulo the frameCount()..PPFor \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, etc..PPThe \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..PPIf 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.).PPSee 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..PPReturns 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..PPSee also leftEdge(), rightEdge() and bottomEdge()..SH "int QCanvasSprite::width () const"The width of the sprite for the current frame's image..PPSee also frame()..SH "SEE ALSO".BR http://doc.trolltech.com/qcanvassprite.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf 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 Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -