summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqcanvassprite.3qt
blob: 8a3e194b83240029657afef60dbfdb0eb3642957 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
'\" 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 <ntqcanvas.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 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 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 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).