-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplosion.cpp
36 lines (33 loc) · 994 Bytes
/
explosion.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*************************************************************************
> File Name: explosion.cpp
> Author: Polaris-hzn8
> Mail: [email protected]
> Created Time: 2023-08-19 13:29:19
************************************************************************/
#include "config.h"
#include "explosion.h"
Explosion::Explosion() {
//成员变量初始化
_x = 0;
_y = 0;
_idx = 0;
_isPlaying = false;
_timestamp = 0;
for (int i = 0; i < EXPLOSION_IMG_MAXINDEX; ++i) {
QString imgPath = QString(EXPLOSION_IMG_PATH).arg(i + 1);
_picArray.push_back(QPixmap(imgPath));
}
}
void Explosion::updateExplosionIMG() {
if (!_isPlaying) return;
else {
_timestamp++;
if (_timestamp < EXPLOSION_IMG_INTERVAL) return;
else {
//爆炸效果开始播放
_timestamp = 0;
_idx++;
if (_idx >= EXPLOSION_IMG_MAXINDEX) { _idx = 0; _isPlaying = false; }
}
}
}