qcanvassprite.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 293 行 · 第 1/2 页

HTML
293
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/canvas/qcanvas.cpp:2367 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QCanvasSprite Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasSprite Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1><p>The QCanvasSprite class provides an animated canvas item on a QCanvas.<a href="#details">More...</a><p><tt>#include &lt;<a href="qcanvas-h.html">qcanvas.h</a>&gt;</tt><p>Inherits <a href="qcanvasitem.html">QCanvasItem</a>.<p><a href="qcanvassprite-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QCanvasSprite"><b>QCanvasSprite</b></a> ( QCanvasPixmapArray&nbsp;*&nbsp;a, QCanvas&nbsp;*&nbsp;canvas )</div></li><li><div class=fn>void <a href="#setSequence"><b>setSequence</b></a> ( QCanvasPixmapArray&nbsp;*&nbsp;a )</div></li><li><div class=fn>virtual <a href="#~QCanvasSprite"><b>~QCanvasSprite</b></a> ()</div></li><li><div class=fn>virtual void <a href="#move"><b>move</b></a> ( double&nbsp;nx, double&nbsp;ny, int&nbsp;nf )</div></li><li><div class=fn>void <a href="#setFrame"><b>setFrame</b></a> ( int&nbsp;f )</div></li><li><div class=fn>enum <a href="#FrameAnimationType-enum"><b>FrameAnimationType</b></a> { Cycle, Oscillate }</div></li><li><div class=fn>virtual void <a href="#setFrameAnimation"><b>setFrameAnimation</b></a> ( FrameAnimationType&nbsp;type = Cycle, int&nbsp;step = 1, int&nbsp;state = 0 )</div></li><li><div class=fn>int <a href="#frame"><b>frame</b></a> () const</div></li><li><div class=fn>int <a href="#frameCount"><b>frameCount</b></a> () const</div></li><li><div class=fn>virtual int <a href="#rtti"><b>rtti</b></a> () const</div></li><li><div class=fn>virtual QRect <a href="#boundingRect"><b>boundingRect</b></a> () const</div></li><li><div class=fn>int <a href="#width"><b>width</b></a> () const</div></li><li><div class=fn>int <a href="#height"><b>height</b></a> () const</div></li><li><div class=fn>int <a href="#leftEdge"><b>leftEdge</b></a> () const</div></li><li><div class=fn>int <a href="#topEdge"><b>topEdge</b></a> () const</div></li><li><div class=fn>int <a href="#rightEdge"><b>rightEdge</b></a> () const</div></li><li><div class=fn>int <a href="#bottomEdge"><b>bottomEdge</b></a> () const</div></li><li><div class=fn>int <a href="#leftEdge-2"><b>leftEdge</b></a> ( int&nbsp;nx ) const</div></li><li><div class=fn>int <a href="#topEdge-2"><b>topEdge</b></a> ( int&nbsp;ny ) const</div></li><li><div class=fn>int <a href="#rightEdge-2"><b>rightEdge</b></a> ( int&nbsp;nx ) const</div></li><li><div class=fn>int <a href="#bottomEdge-2"><b>bottomEdge</b></a> ( int&nbsp;ny ) const</div></li><li><div class=fn>QCanvasPixmap * <a href="#image"><b>image</b></a> () const</div></li><li><div class=fn>virtual QCanvasPixmap * <a href="#imageAdvanced"><b>imageAdvanced</b></a> () const</div></li><li><div class=fn>QCanvasPixmap * <a href="#image-2"><b>image</b></a> ( int&nbsp;f ) const</div></li><li><div class=fn>virtual void <a href="#advance"><b>advance</b></a> ( int&nbsp;phase )</div></li><li><div class=fn>virtual void <a href="#draw"><b>draw</b></a> ( QPainter&nbsp;&amp;&nbsp;painter )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QCanvasSprite class provides an animated canvas item on a <a href="qcanvas.html">QCanvas</a>.<p> 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 theconstructor or set or changed later with <a href="#setSequence">setSequence</a>(). If yousubclass QCanvasSprite you can change the frame that is displayedperiodically, e.g. whenever <a href="qcanvasitem.html#advance">QCanvasItem::advance</a>(1) is called tocreate the effect of animation.<p> The current frame can be set with <a href="#setFrame">setFrame</a>() or with <a href="#move">move</a>(). Thenumber of frames available is given by <a href="#frameCount">frameCount</a>(). The boundingrectangle of the current frame is returned by <a href="#boundingRect">boundingRect</a>().<p> The current frame's image can be retrieved with <a href="#image">image</a>(); use<a href="#imageAdvanced">imageAdvanced</a>() to retrieve the image for the frame that will beshown after <a href="#advance">advance</a>(1) is called. Use the image() overload passingit an integer index to retrieve a particular image from the list offrames.<p> Use <a href="#width">width</a>() and <a href="#height">height</a>() to retrieve the dimensions of the currentframe.<p> Use <a href="#leftEdge">leftEdge</a>() and <a href="#rightEdge">rightEdge</a>() to retrieve the current frame'sleft-hand and right-hand x-coordinates respectively. Use<a href="#bottomEdge">bottomEdge</a>() and <a href="#topEdge">topEdge</a>() to retrieve the current frame's bottomand top y-coordinates respectively. These functions have an overloadwhich will accept an integer frame number to retrieve thecoordinates of a particular frame.<p> QCanvasSprite draws very quickly, at the expense of memory.<p> The current frame's image can be drawn on a painter with <a href="#draw">draw</a>().<p> Like any other canvas item, canvas sprites can be moved with <a href="#move">move</a>()which sets the x and y coordinates and the frame number, as well aswith <a href="qcanvasitem.html#move">QCanvasItem::move</a>() and <a href="qcanvasitem.html#moveBy">QCanvasItem::moveBy</a>(), or by settingcoordinates with <a href="qcanvasitem.html#setX">QCanvasItem::setX</a>(), <a href="qcanvasitem.html#setY">QCanvasItem::setY</a>() and<a href="qcanvasitem.html#setZ">QCanvasItem::setZ</a>().<p> <p>See also <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="FrameAnimationType-enum"></a>QCanvasSprite::FrameAnimationType</h3><p> This enum is used to identify the different types of frameanimation of QCanvasSprite.<ul><li><tt>QCanvasSprite::Cycle</tt> - at each advance the frame number will be incremented by1 (modulo the frame count).<li><tt>QCanvasSprite::Oscillate</tt> - at each advance the frame number will beincremented by 1 up to the frame count then decremented to by 1 to0, repeating this sequence forever.</ul><hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QCanvasSprite"></a>QCanvasSprite::QCanvasSprite ( <a href="qcanvaspixmaparray.html">QCanvasPixmapArray</a>&nbsp;*&nbsp;a, <a href="qcanvas.html">QCanvas</a>&nbsp;*&nbsp;canvas )</h3>Constructs a QCanvasSprite which uses images from the <a href="qcanvaspixmaparray.html">QCanvasPixmapArray</a><em>a</em>.<p> The sprite in initially positioned at (0,0) on <em>canvas</em>, using frame 0.<h3 class=fn><a name="~QCanvasSprite"></a>QCanvasSprite::~QCanvasSprite ()<tt> [virtual]</tt></h3>Destroys the sprite and removes it from the canvas. Does <em>not</em> deletethe images.<h3 class=fn>void <a name="advance"></a>QCanvasSprite::advance ( int&nbsp;phase )<tt> [virtual]</tt></h3>Extends the default <a href="qcanvasitem.html">QCanvasItem</a> implementation to providethe functionality of <a href="#setFrameAnimation">setFrameAnimation</a>().<p> The <em>phase</em> is 0 or 1: see QCanvas::animate() for details.<p> <p>See also <a href="qcanvasitem.html#advance">QCanvasItem::advance</a>() and <a href="qcanvasitem.html#setVelocity">setVelocity</a>().<p>Example: <a href="canvas-example.html#x2703">canvas/canvas.cpp</a>.<p>Reimplemented from <a href="qcanvasitem.html#advance">QCanvasItem</a>.<h3 class=fn>int <a name="bottomEdge"></a>QCanvasSprite::bottomEdge () const</h3> Returns the y-coordinate of the current bottom edge of thesprite. (This may change as the sprite animates since different framesmay have different bottom edges.)<p> <p>See also <a href="#leftEdge">leftEdge</a>(), <a href="#rightEdge">rightEdge</a>() and <a href="#topEdge">topEdge</a>().<h3 class=fn>int <a name="bottomEdge-2"></a>QCanvasSprite::bottomEdge ( int&nbsp;ny ) const</h3>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?