Class hierarchy Compound list File list Compound Members

# Sprite Class Reference

A Sprite is a 2D entity that basically gives a body to a bitmap. More...

Inherits SpriteSelector.

List of all members.

## Public Members

- Sprite (Bitmap* BM, int Solid=0)
    Construct a sprite from a bitmap.

- Sprite (Bitmap* BM, Rect2D& r, int Solid=0)
    Construct a sprite from a section(Rect2D r) of a bitmap.

- virtual ~Sprite ()
    Destruct the Sprite.

- long render (const Vector2D& pos, const View2D& view)
    render the sprite to position pos within a 2D view.

- int collision (Sprite& S, int dx, int dy) const
    Test for collision with this sprite.

- void setSolid (int Solid)
    Set the solid (collision detection state) of the Sprite.

- int getSolid () const
    Retrieve the Solid (collision detection) state of the sprite.

- int getWidth () const
    Retrieve the sprite's bitmap width.

- int getHeight () const
    Retrieve the sprite's bitmap height.

- Vector2D getPos () const
    Return the offset into the bitmap, where the sprite is located.

- Rect2D getRect () const
    Return the rectangle in the bitmap, where the sprite is located.

- virtual Sprite* getSprite ()
    Implementation of the abstract SpriteSelector.

- Bitmap* getBitmap () const
    Retrieve the sprite's associated bitmap.

- void setBitmap (Bitmap* BM, Rect2D r=Rect2D(), int Solid=-1)
    Set a new bitmap for this sprite (and optionally new rectangle) Recalcuates collision detection info according to Solid parameter.

- void setBitmapOwner (int Owner=1)
    Set the sprite as the bitmap owner, which means that it will release an old bitmap before setting a new one.

## Detailed Description

A Sprite is a 2D entity that basically gives a body to a bitmap.

This means for example, supplying a collision detection between two sprites. The first pixel (0,0) is used to determine the transparent color, which is considered the 'outside' of the sprite.

## Member Function Documentation

### Sprite::Sprite(Bitmap* BM, int Solid=0)

Construct a sprite from a bitmap.

If Solid is non zero, collision detection is enabled for this sprite.

### Sprite::Sprite(Bitmap* BM, Rect2D& r, int Solid=0)

Construct a sprite from a section(Rect2D r) of a bitmap.

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

Destruct the Sprite.

### long Sprite::render(const Vector2D& pos, const View2D& view)

render the sprite to position pos within a 2D view.

### int Sprite::collision(Sprite& S, int dx, int dy) const

Test for collision with this sprite.

The offset describes the location of the other sprite relative to this one.

### void Sprite::setSolid(int Solid)

Set the solid (collision detection state) of the Sprite.

If the sprite was created with Solid=0, it cannot be switched to Solid. This is useful to make Solid sprites transparent.

### int Sprite::getSolid() const

Retrieve the Solid (collision detection) state of the sprite.

### int Sprite::getWidth() const

Retrieve the sprite's bitmap width.

### int Sprite::getHeight() const

Retrieve the sprite's bitmap height.

### Vector2D Sprite::getPos() const

Return the offset into the bitmap, where the sprite is located.

### Rect2D Sprite::getRect() const

Return the rectangle in the bitmap, where the sprite is located.

### virtual Sprite* Sprite::getSprite()`[virtual]`

Implementation of the abstract SpriteSelector.

Simply returns this sprite.

Reimplemented from SpriteSelector.

### Bitmap* Sprite::getBitmap() const

Retrieve the sprite's associated bitmap.

### void Sprite::setBitmap(Bitmap* BM, Rect2D r=Rect2D(), int Solid=-1)

Set a new bitmap for this sprite (and optionally new rectangle) Recalcuates collision detection info according to Solid parameter.

if Solid == -1 (default), collision info is calculated if it was already present. if Solid == 0, collsion info is not calculated; otherwise, collision info is calculated.

### void Sprite::setBitmapOwner(int Owner=1)

Set the sprite as the bitmap owner, which means that it will release an old bitmap before setting a new one.

Useful for objects not using the bitmap caching.

The documentation for this class was generated from the following file:

- 2D_Object2D.h