ManaPlus
Public Member Functions | Private Attributes
TileAnimation Class Reference

#include <tileanimation.h>

Public Member Functions

 TileAnimation (Animation *const ani)
 
 ~TileAnimation ()
 
bool update (const int ticks)
 
void addAffectedTile (MapLayer *const layer, const int index)
 

Private Attributes

TilePairVector mAffected
 
SimpleAnimationmAnimation
 
ImagemLastImage
 

Detailed Description

Animation cycle of a tile image which changes the map accordingly.

Definition at line 44 of file tileanimation.h.

Constructor & Destructor Documentation

◆ TileAnimation()

TileAnimation::TileAnimation ( Animation *const  ani)
explicit

Definition at line 35 of file tileanimation.cpp.

35  :
36  mAffected(),
37  mAnimation(new SimpleAnimation(ani)),
38  mLastImage(nullptr)
39 {
40 }
SimpleAnimation * mAnimation
Definition: tileanimation.h:60
TilePairVector mAffected
Definition: tileanimation.h:59
Image * mLastImage
Definition: tileanimation.h:61

◆ ~TileAnimation()

TileAnimation::~TileAnimation ( )

Definition at line 42 of file tileanimation.cpp.

43 {
45 }
#define delete2(var)
Definition: delete2.h:25

References delete2, and mAnimation.

Member Function Documentation

◆ addAffectedTile()

void TileAnimation::addAffectedTile ( MapLayer *const  layer,
const int  index 
)
inline

Definition at line 55 of file tileanimation.h.

56  { mAffected.push_back(std::make_pair(layer, index)); }

References mAffected.

Referenced by MapReader::readBase64Layer(), MapReader::readCsvLayer(), and MapReader::readLayer().

◆ update()

bool TileAnimation::update ( const int  ticks)

Definition at line 47 of file tileanimation.cpp.

48 {
49  if (mAnimation == nullptr)
50  return false;
51 
52  // update animation
53  if (!mAnimation->update(ticks))
54  return false;
55 
56  // exchange images
57  Image *const img = mAnimation->getCurrentImage();
58  if (img != mLastImage)
59  {
61  {
62  if (i->first != nullptr)
63  i->first->setTile(i->second, img);
64  }
65  mLastImage = img;
66  }
67  return true;
68 }
bool update(const int timePassed)
Image * getCurrentImage() const
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
TilePairVector::const_iterator TilePairVectorCIter
Definition: tileanimation.h:39

References FOR_EACH, SimpleAnimation::getCurrentImage(), mAffected, mAnimation, mLastImage, and SimpleAnimation::update().

Field Documentation

◆ mAffected

TilePairVector TileAnimation::mAffected
private

Definition at line 59 of file tileanimation.h.

Referenced by addAffectedTile(), and update().

◆ mAnimation

SimpleAnimation* TileAnimation::mAnimation
private

Definition at line 60 of file tileanimation.h.

Referenced by update(), and ~TileAnimation().

◆ mLastImage

Image* TileAnimation::mLastImage
private

Definition at line 61 of file tileanimation.h.

Referenced by update().


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