# QwPositionedSprite Class Reference

A QwVirtualSprite with a stored position and frame number. More...

`#include <QwSpriteField.h>`

Inherits QwVirtualSprite.

List of all member functions.

## Public Members

- QwPositionedSprite ( QwSpritePixmapSequence * seq )
- QwPositionedSprite ()
- void setSequence ( QwSpritePixmapSequence * seq )
- virtual ~QwPositionedSprite ()
- void frame ( int f )
- int frame () const
- int frameCount () const
- virtual int x () const
- virtual int y () const
- COORD exact_x () const
- COORD exact_y () const
- void x ( COORD nx )
- void y ( COORD ny )
- void moveBy ( COORD dx, COORD dy )
- void moveTo ( COORD nx, COORD ny )
- virtual void moveTo ( COORD nx, COORD ny, int nf )
- virtual int z () const
- void z ( int a )
- virtual int rtti () const
- Pix neighbourhood ( int nframe ) const
- Pix neighbourhood ( int nx, int ny ) const
- Pix neighbourhood ( COORD nx, COORD ny, int nframe ) const
- bool wouldHit ( QwSpriteFieldGraphic & other, COORD x, COORD y, int frame ) const

## Detailed Description

A QwVirtualSprite with a stored position and frame number.

This is a template class which allows any numerical class to be used as the stored coordinate type of a QwVirtualSprite. Two derived classes, QwSprite and QwRealSprite provide \t integer and \t double instantiations of this class.

## Member Function Documentation

### QwPositionedSprite::QwPositionedSprite ()

Create a QwPositionedSprite<COORD> without defining its image sequence.

The sprite in initially at (0,0) on the current spritefield (see constructor for QwSpriteField), using the 0th sequence frame.

Note that you must call setSequence(QwSpritePixmapSequence*) before doing anything else with the sprite.

### QwPositionedSprite::QwPositionedSprite ( QwSpritePixmapSequence * seq )

Create a QwPositionedSprite<COORD> which uses images from the given sequence.

The sprite in initially at (0,0) on the current spritefield (see constructor for QwSpriteField), using the 0th sequence frame.

### QwPositionedSprite::~QwPositionedSprite () `[virtual]`

Destruct the sprite. It is removed from its QwSpriteField in this process.

### COORD QwPositionedSprite::exact_x () const

Returns the X-position, in COORD units rather than the integer pixel coordinates used by the graphical engine.

### COORD QwPositionedSprite::exact_y () const

Returns the Y-position, in COORD units rather than the integer pixel coordinates used by the graphical engine.

### int QwPositionedSprite::frame () const

Returns the index into the QwPositionedSprite<COORD>'s QwSpritePixmapSequence of the current animation frame.

See also: moveTo(COORD,COORD,int).

### void QwPositionedSprite::frame ( int f )

Set the animation frame used for displaying the sprite to the given index into the QwPositionedSprite<COORD>'s QwSpritePixmapSequence.

See also: moveTo(COORD,COORD,int).

### int QwPositionedSprite::frameCount () const

Returns the number of frames in the QwPositionedSprite<COORD>'s QwSpritePixmapSequence.

### void QwPositionedSprite::moveBy ( COORD dx, COORD dy )

Move the sprite from its current position by the given amounts.

### void QwPositionedSprite::moveTo ( COORD nx, COORD ny )

Move the sprite to the given absolute position.

See also: moveBy(COORD,COORD) and moveTo(COORD,COORD,int).

### void QwPositionedSprite::moveTo ( COORD nx, COORD ny, int nf ) `[virtual]`

Set both the position and the frame of the sprite.

### Pix QwPositionedSprite::neighbourhood ( COORD nx, COORD ny, int nframe ) const

Similar to QwVirtualSprite::neighbourhood(int x, int y, QwSpritePixmap*), but the image is specified by index rather than actual value.

### Pix QwPositionedSprite::neighbourhood ( int nframe ) const

Similar to QwVirtualSprite::neighbourhood(QwSpritePixmap*), but the image is specified by index rather than actual value.

### Pix QwPositionedSprite::neighbourhood ( int nx, int ny ) const

Same as QwVirtualSprite::neighbourhood(int x, int y).

### int QwPositionedSprite::rtti () const `[virtual]`

Returns 2.

See also: QwSpriteFieldGraphic::rtti().

### void QwPositionedSprite::setSequence ( QwSpritePixmapSequence * seq )

Set the sequence of images used for displaying the sprite. Note that the sequence should have enough images for the sprites current frame() to be valid.

### bool QwPositionedSprite::wouldHit ( QwSpriteFieldGraphic & other, COORD x, COORD y, int frame ) const

Similar to QwVirtualSprite::wouldHit(QwSpriteFieldGraphic&, int x, int y, QwSpritePixmap*), but the image is specified by index rather than actual value.

### int QwPositionedSprite::x () const `[virtual]`

Returns the stored horizontal position of the sprite.

### void QwPositionedSprite::x ( COORD nx )

Set the horizontal position of the sprite.

See also: moveTo(COORD,COORD).

### int QwPositionedSprite::y () const `[virtual]`

Returns the stored vertical position of the sprite.

### void QwPositionedSprite::y ( COORD ny )

Set the vertical position of the sprite.

See also: moveTo(COORD,COORD).

### int QwPositionedSprite::z () const `[virtual]`

Returns the stored z of the sprite.

### void QwPositionedSprite::z ( int a )

Sets the stored z of the sprite.

This file is copyright © 1995-97 Warwick Allison.

It was generated from the following files:

- QwSpriteField.h
- QwSpriteField-double.cpp
- QwSpriteField-int.cpp
- QwSpriteField-mobdouble.cpp
- QwSpriteField-mobint.cpp
- QwSpriteField-template.cpp
- QwSpriteField.cpp