1QCanvasSprite(3qt)                                          QCanvasSprite(3qt)
2
3
4

NAME

6       QCanvasSprite - Animated canvas item on a QCanvas
7

SYNOPSIS

9       #include <qcanvas.h>
10
11       Inherits QCanvasItem.
12
13   Public Members
14       QCanvasSprite ( QCanvasPixmapArray * a, QCanvas * canvas )
15       void setSequence ( QCanvasPixmapArray * a )
16       virtual ~QCanvasSprite ()
17       virtual void move ( double nx, double ny, int nf )
18       void setFrame ( int f )
19       enum FrameAnimationType { Cycle, Oscillate }
20       virtual void setFrameAnimation ( FrameAnimationType type = Cycle, int
21           step = 1, int state = 0 )
22       int frame () const
23       int frameCount () const
24       virtual int rtti () const
25       virtual QRect boundingRect () const
26       int width () const
27       int height () const
28       int leftEdge () const
29       int topEdge () const
30       int rightEdge () const
31       int bottomEdge () const
32       int leftEdge ( int nx ) const
33       int topEdge ( int ny ) const
34       int rightEdge ( int nx ) const
35       int bottomEdge ( int ny ) const
36       QCanvasPixmap * image () const
37       virtual QCanvasPixmap * imageAdvanced () const
38       QCanvasPixmap * image ( int f ) const
39       virtual void advance ( int phase )
40       virtual void draw ( QPainter & painter )
41

DESCRIPTION

43       The QCanvasSprite class provides an animated canvas item on a QCanvas.
44
45       A canvas sprite is an object which can contain any number of images
46       (referred to as frames), only one of which is current, i.e. displayed,
47       at any one time. The images can be passed in the constructor or set or
48       changed later with setSequence(). If you subclass QCanvasSprite you can
49       change the frame that is displayed periodically, e.g. whenever
50       QCanvasItem::advance(1) is called to create the effect of animation.
51
52       The current frame can be set with setFrame() or with move(). The number
53       of frames available is given by frameCount(). The bounding rectangle of
54       the current frame is returned by boundingRect().
55
56       The current frame's image can be retrieved with image(); use
57       imageAdvanced() to retrieve the image for the frame that will be shown
58       after advance(1) is called. Use the image() overload passing it an
59       integer index to retrieve a particular image from the list of frames.
60
61       Use width() and height() to retrieve the dimensions of the current
62       frame.
63
64       Use leftEdge() and rightEdge() to retrieve the current frame's left-
65       hand and right-hand x-coordinates respectively. Use bottomEdge() and
66       topEdge() to retrieve the current frame's bottom and top y-coordinates
67       respectively. These functions have an overload which will accept an
68       integer frame number to retrieve the coordinates of a particular frame.
69
70       QCanvasSprite draws very quickly, at the expense of memory.
71
72       The current frame's image can be drawn on a painter with draw().
73
74       Like any other canvas item, canvas sprites can be moved with move()
75       which sets the x and y coordinates and the frame number, as well as
76       with QCanvasItem::move() and QCanvasItem::moveBy(), or by setting
77       coordinates with QCanvasItem::setX(), QCanvasItem::setY() and
78       QCanvasItem::setZ().
79
80       See also Graphics Classes and Image Processing Classes.
81
82   Member Type Documentation

QCanvasSprite::FrameAnimationType

84       This enum is used to identify the different types of frame animation
85       offered by QCanvasSprite.
86
87       QCanvasSprite::Cycle - at each advance the frame number will be
88       incremented by 1 (modulo the frame count).
89
90       QCanvasSprite::Oscillate - at each advance the frame number will be
91       incremented by 1 up to the frame count then decremented to by 1 to 0,
92       repeating this sequence forever.
93

MEMBER FUNCTION DOCUMENTATION

QCanvasSprite::QCanvasSprite ( QCanvasPixmapArray * a, QCanvas * canvas )

96       Constructs a QCanvasSprite which uses images from the
97       QCanvasPixmapArray a.
98
99       The sprite in initially positioned at (0, 0) on canvas, using frame 0.
100

QCanvasSprite::~QCanvasSprite () [virtual]

102       Destroys the sprite and removes it from the canvas. Does not delete the
103       images.
104

void QCanvasSprite::advance ( int phase ) [virtual]

106       Extends the default QCanvasItem implementation to provide the
107       functionality of setFrameAnimation().
108
109       The phase is 0 or 1: see QCanvasItem::advance() for details.
110
111       See also QCanvasItem::advance() and setVelocity().
112
113       Example: canvas/canvas.cpp.
114
115       Reimplemented from QCanvasItem.
116

int QCanvasSprite::bottomEdge () const

118       Returns the y-coordinate of the current bottom edge of the sprite.
119       (This may change as the sprite animates since different frames may have
120       different bottom edges.)
121
122       See also leftEdge(), rightEdge(), and topEdge().
123

int QCanvasSprite::bottomEdge ( int ny ) const

125       This is an overloaded member function, provided for convenience. It
126       behaves essentially like the above function.
127
128       Returns what the y-coordinate of the top edge of the sprite would be if
129       the sprite (actually its hotspot) were moved to y-position ny.
130
131       See also leftEdge(), rightEdge(), and topEdge().
132

QRect QCanvasSprite::boundingRect () const [virtual]

134       Returns the bounding rectangle for the image in the sprite's current
135       frame. This assumes that the images are tightly cropped (i.e. do not
136       have transparent pixels all along a side).
137
138       Reimplemented from QCanvasItem.
139

void QCanvasSprite::draw ( QPainter & painter ) [virtual]

141       Draws the current frame's image at the sprite's current position on
142       painter painter.
143
144       Reimplemented from QCanvasItem.
145

int QCanvasSprite::frame () const

147       Returns the index of the current animation frame in the QCanvasSprite's
148       QCanvasPixmapArray.
149
150       See also setFrame() and move().
151

int QCanvasSprite::frameCount () const

153       Returns the number of frames in the QCanvasSprite's QCanvasPixmapArray.
154

int QCanvasSprite::height () const

156       The height of the sprite for the current frame's image.
157
158       See also frame().
159

QCanvasPixmap * QCanvasSprite::image () const

161       Returns the current frame's image.
162
163       See also frame() and setFrame().
164

QCanvasPixmap * QCanvasSprite::image ( int f ) const

166       This is an overloaded member function, provided for convenience. It
167       behaves essentially like the above function.
168
169       Returns the image for frame f. Does not do any bounds checking on f.
170

QCanvasPixmap * QCanvasSprite::imageAdvanced () const [virtual]

172       Returns the image the sprite will have after advance(1) is called. By
173       default this is the same as image().
174

int QCanvasSprite::leftEdge () const

176       Returns the x-coordinate of the current left edge of the sprite. (This
177       may change as the sprite animates since different frames may have
178       different left edges.)
179
180       See also rightEdge(), bottomEdge(), and topEdge().
181

int QCanvasSprite::leftEdge ( int nx ) const

183       This is an overloaded member function, provided for convenience. It
184       behaves essentially like the above function.
185
186       Returns what the x-coordinate of the left edge of the sprite would be
187       if the sprite (actually its hotspot) were moved to x-position nx.
188
189       See also rightEdge(), bottomEdge(), and topEdge().
190

void QCanvasSprite::move ( double nx, double ny, int nf ) [virtual]

192       Set the position of the sprite to nx, ny and the current frame to nf.
193       nf will be ignored if it is larger than frameCount() or smaller than 0.
194

int QCanvasSprite::rightEdge () const

196       Returns the x-coordinate of the current right edge of the sprite. (This
197       may change as the sprite animates since different frames may have
198       different right edges.)
199
200       See also leftEdge(), bottomEdge(), and topEdge().
201

int QCanvasSprite::rightEdge ( int nx ) const

203       This is an overloaded member function, provided for convenience. It
204       behaves essentially like the above function.
205
206       Returns what the x-coordinate of the right edge of the sprite would be
207       if the sprite (actually its hotspot) were moved to x-position nx.
208
209       See also leftEdge(), bottomEdge(), and topEdge().
210

int QCanvasSprite::rtti () const [virtual]

212       Returns 1 (QCanvasItem::Rtti_Sprite).
213
214       See also QCanvasItem::rtti().
215
216       Example: canvas/canvas.cpp.
217
218       Reimplemented from QCanvasItem.
219

void QCanvasSprite::setFrame ( int f )

221       Sets the animation frame used for displaying the sprite to f, an index
222       into the QCanvasSprite's QCanvasPixmapArray. The call will be ignored
223       if f is larger than frameCount() or smaller than 0.
224
225       See also frame() and move().
226

void QCanvasSprite::setFrameAnimation ( FrameAnimationType type = Cycle, int

228       step = 1, int state = 0 ) [virtual]
229       Sets the animation characteristics for the sprite.
230
231       For type == Cycle, the frames will increase by step at each advance,
232       modulo the frameCount().
233
234       For type == Oscillate, the frames will increase by step at each
235       advance, up to the frameCount(), then decrease by step back to 0,
236       repeating forever.
237
238       The state parameter is for internal use.
239

void QCanvasSprite::setSequence ( QCanvasPixmapArray * a )

241       Set the array of images used for displaying the sprite to the
242       QCanvasPixmapArray a.
243
244       If the current frame() is larger than the number of images in a, the
245       current frame will be reset to 0.
246

int QCanvasSprite::topEdge () const

248       Returns the y-coordinate of the top edge of the sprite. (This may
249       change as the sprite animates since different frames may have different
250       top edges.)
251
252       See also leftEdge(), rightEdge(), and bottomEdge().
253

int QCanvasSprite::topEdge ( int ny ) const

255       This is an overloaded member function, provided for convenience. It
256       behaves essentially like the above function.
257
258       Returns what the y-coordinate of the top edge of the sprite would be if
259       the sprite (actually its hotspot) were moved to y-position ny.
260
261       See also leftEdge(), rightEdge(), and bottomEdge().
262

int QCanvasSprite::width () const

264       The width of the sprite for the current frame's image.
265
266       See also frame().
267
268

SEE ALSO

270       http://doc.trolltech.com/qcanvassprite.html
271       http://www.trolltech.com/faq/tech.html
272
274       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
275       license file included in the distribution for a complete license
276       statement.
277

AUTHOR

279       Generated automatically from the source code.
280

BUGS

282       If you find a bug in Qt, please report it as described in
283       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
284       help you. Thank you.
285
286       The definitive Qt documentation is provided in HTML format; it is
287       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
288       web browser. This man page is provided as a convenience for those users
289       who prefer man pages, although this format is not officially supported
290       by Trolltech.
291
292       If you find errors in this manual page, please report them to qt-
293       bugs@trolltech.com.  Please include the name of the manual page
294       (qcanvassprite.3qt) and the Qt version (3.3.8).
295
296
297
298Trolltech AS                    2 February 2007             QCanvasSprite(3qt)
Impressum