Definition at line 16 of file Anim.h.
Public Types | |
enum | eSide { SIDE_LEFT = 0, SIDE_RIGHT = 1 } |
Public Member Functions | |
Anim () | |
Create new animation sprite. | |
virtual | ~Anim () |
void | drawAt (SDL_Surface *screen, int x, int y, eSide side) |
Draw anim phase at screen position. | |
void | addAnim (const std::string &name, const Path &picture, eSide side=SIDE_LEFT) |
Add picture to anim, default side is left side. | |
void | runAnim (const std::string &name, int start_phase=0) |
Run this animation. | |
void | setAnim (const std::string &name, int phase) |
Set static visage. | |
void | useSpecialAnim (const std::string &name, int phase) |
Use special efect for one phase. | |
bool | isDisintegrated () const |
bool | isInvisible () const |
void | changeEffect (ViewEffect *new_effect) |
Change effect. | |
void | setViewShift (const V2 &shift) |
V2 | getViewShift () const |
int | countAnimPhases (const std::string &anim, eSide side=SIDE_LEFT) const |
|
Definition at line 18 of file Anim.h. 00018 { 00019 SIDE_LEFT = 0, 00020 SIDE_RIGHT = 1 00021 };
|
|
Create new animation sprite.
Definition at line 21 of file Anim.cpp. 00022 : m_viewShift(0, 0) 00023 { 00024 m_animPack[SIDE_LEFT] = new ResImagePack(); 00025 m_animPack[SIDE_RIGHT] = new ResImagePack(); 00026 00027 m_animName = ""; 00028 m_animPhase = 0; 00029 m_run = false; 00030 m_specialAnimName = ""; 00031 m_specialAnimPhase = 0; 00032 m_effect = new EffectNone(); 00033 }
|
|
Definition at line 35 of file Anim.cpp. 00036 { 00037 m_animPack[SIDE_LEFT]->removeAll(); 00038 m_animPack[SIDE_RIGHT]->removeAll(); 00039 delete m_animPack[SIDE_LEFT]; 00040 delete m_animPack[SIDE_RIGHT]; 00041 delete m_effect; 00042 }
|
|
Add picture to anim, default side is left side.
Definition at line 78 of file Anim.cpp. 00079 { 00080 m_usedPath = picture.getPosixName(); 00081 m_animPack[side]->addImage(name, picture); 00082 }
|
|
Change effect.
Definition at line 157 of file Anim.cpp. 00158 { 00159 if (NULL == new_effect) { 00160 throw LogicException(ExInfo("new_effect is NULL") 00161 .addInfo("animName", m_animName) 00162 .addInfo("specialAnimName", m_specialAnimName)); 00163 } 00164 00165 delete m_effect; 00166 m_effect = new_effect; 00167 }
|
|
Definition at line 170 of file Anim.cpp. 00171 { 00172 return m_animPack[side]->countRes(anim); 00173 }
|
|
Draw anim phase at screen position. Increase phase when anim is running. Definition at line 49 of file Anim.cpp. 00050 { 00051 if (!m_effect->isInvisible()) { 00052 SDL_Surface *surface = 00053 m_animPack[side]->getRes(m_animName, m_animPhase); 00054 m_effect->blit(screen, surface, x, y); 00055 if (m_run) { 00056 m_animPhase++; 00057 if (m_animPhase >= m_animPack[side]->countRes(m_animName)) { 00058 m_animPhase = 0; 00059 } 00060 } 00061 00062 if (!m_specialAnimName.empty()) { 00063 surface = 00064 m_animPack[side]->getRes(m_specialAnimName, m_specialAnimPhase); 00065 m_effect->blit(screen, surface, x, y); 00066 m_specialAnimName = ""; 00067 } 00068 } 00069 00070 m_effect->updateEffect(); 00071 }
|
|
Definition at line 50 of file Anim.h. 00050 { return m_viewShift; };
|
|
Definition at line 46 of file Anim.h. 00046 { return m_effect->isDisintegrated(); }
|
|
Definition at line 47 of file Anim.h. 00047 { return m_effect->isInvisible(); }
|
|
Run this animation. Nothing is changed when animation is already running. Definition at line 89 of file Anim.cpp. 00090 { 00091 if (m_animName != name) { 00092 setAnim(name, start_phase); 00093 } 00094 m_run = true; 00095 }
|
|
Set static visage.
Definition at line 101 of file Anim.cpp. 00102 { 00103 m_run = false; 00104 m_animName = name; 00105 m_animPhase = phase; 00106 00107 int count = m_animPack[SIDE_LEFT]->countRes(name); 00108 if (m_animPhase >= count) { 00109 if (count == 0) { 00110 m_animPhase = 0; 00111 } 00112 else { 00113 m_animPhase %= count; 00114 } 00115 LOG_WARNING(ExInfo("anim phase over-flow") 00116 .addInfo("anim", name) 00117 .addInfo("phase", phase) 00118 .addInfo("count", count) 00119 .addInfo("usedPath", m_usedPath)); 00120 } 00121 }
|
|
Definition at line 49 of file Anim.h. 00049 { m_viewShift = shift; }
|
|
Use special efect for one phase. Efect will be blited in second layer.
Definition at line 131 of file Anim.cpp. 00132 { 00133 m_specialAnimName = name; 00134 m_specialAnimPhase = phase; 00135 00136 int count = m_animPack[SIDE_LEFT]->countRes(name); 00137 if (m_specialAnimPhase >= count) { 00138 if (count == 0) { 00139 m_specialAnimName = ""; 00140 m_specialAnimPhase = 0; 00141 } 00142 else { 00143 m_specialAnimPhase %= count; 00144 } 00145 LOG_WARNING(ExInfo("special anim phase over-flow") 00146 .addInfo("anim", name) 00147 .addInfo("phase", phase) 00148 .addInfo("count", count)); 00149 } 00150 }
|