stmm-games-doc  0.32.0
Public Member Functions | List of all members
stmg::TileAni Class Reference

Tile animation made of images. More...

Public Member Functions

 TileAni () noexcept
 Constructor. More...
 
void setDefaultImage (const shared_ptr< Image > &refImage) noexcept
 Set the default image. More...
 
const shared_ptr< Image > & getDefaultImage () noexcept
 The default image. More...
 
void addImage (int32_t nDuration, const shared_ptr< Image > &refImage) noexcept
 Adds an image to the tile animation. More...
 
const shared_ptr< Image > & getImage (double fElapsed) noexcept
 The image at a certain point in the animation. More...
 
const shared_ptr< Image > & getImage (double fElapsed, int32_t &nIdx) noexcept
 The image and the index at a certain point in the animation. More...
 
int32_t getTotImages () const noexcept
 The nummber of images added. More...
 
const shared_ptr< Image > & getImageByIdx (int32_t nIdx) noexcept
 The image by index. More...
 

Detailed Description

Tile animation made of images.

Each image in the animation has a duration weight.

The elapsed time is not in milliseconds but a number from 0.0 to 1.0. Elapsed 0.0 is the start of the animation and 1.0 is the end.

Constructor & Destructor Documentation

◆ TileAni()

stmg::TileAni::TileAni ( )
noexcept

Constructor.

Member Function Documentation

◆ addImage()

void stmg::TileAni::addImage ( int32_t  nDuration,
const shared_ptr< Image > &  refImage 
)
noexcept

Adds an image to the tile animation.

Parameters
nDurationThe duration weight. Must be a positive number.
refImageThe image. Can be null.

◆ getDefaultImage()

const shared_ptr<Image>& stmg::TileAni::getDefaultImage ( )
noexcept

The default image.

Returns
The default image or null.

◆ getImage() [1/2]

const shared_ptr<Image>& stmg::TileAni::getImage ( double  fElapsed)
noexcept

The image at a certain point in the animation.

If no image was added the default image is returned.

Parameters
fElapsedThe elapsed "time". Must be >= 0.0 and <= 1.0.
Returns
The image or null.

◆ getImage() [2/2]

const shared_ptr<Image>& stmg::TileAni::getImage ( double  fElapsed,
int32_t &  nIdx 
)
noexcept

The image and the index at a certain point in the animation.

If no image was added index -1 and the default image is returned.

Parameters
fElapsedThe elapsed "time". Must be >= 0.0 and <= 1.0.
nIdxThe index of the image or -1 if none was added. (output).
Returns
The image or null.

◆ getImageByIdx()

const shared_ptr<Image>& stmg::TileAni::getImageByIdx ( int32_t  nIdx)
noexcept

The image by index.

Parameters
nIdxThe index. Must be >= 0 and < getTotImages().
Returns
The image or null.

◆ getTotImages()

int32_t stmg::TileAni::getTotImages ( ) const
noexcept

The nummber of images added.

Returns
The total number of images.

◆ setDefaultImage()

void stmg::TileAni::setDefaultImage ( const shared_ptr< Image > &  refImage)
noexcept

Set the default image.

The default image can only be set once.

Parameters
refImageThe default image. Can be null.