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 43 of file tileanimation.h.

Constructor & Destructor Documentation

◆ TileAnimation()

TileAnimation::TileAnimation ( Animation *const  ani)
explicit

Definition at line 34 of file tileanimation.cpp.

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

◆ ~TileAnimation()

TileAnimation::~TileAnimation ( )

Definition at line 41 of file tileanimation.cpp.

References delete2, and mAnimation.

42 {
44 }
#define delete2(var)
Definition: delete2.h:24
SimpleAnimation * mAnimation
Definition: tileanimation.h:59

Member Function Documentation

◆ addAffectedTile()

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

Definition at line 54 of file tileanimation.h.

References mAffected.

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

55  { mAffected.push_back(std::make_pair(layer, index)); }
TilePairVector mAffected
Definition: tileanimation.h:58

◆ update()

bool TileAnimation::update ( const int  ticks)

Definition at line 46 of file tileanimation.cpp.

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

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

Field Documentation

◆ mAffected

TilePairVector TileAnimation::mAffected
private

Definition at line 58 of file tileanimation.h.

Referenced by addAffectedTile(), and update().

◆ mAnimation

SimpleAnimation* TileAnimation::mAnimation
private

Definition at line 59 of file tileanimation.h.

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

◆ mLastImage

Image* TileAnimation::mLastImage
private

Definition at line 60 of file tileanimation.h.

Referenced by update().


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