forked from Littlefean/Minecraft2D
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBar.cpp
More file actions
49 lines (41 loc) · 825 Bytes
/
ProgressBar.cpp
File metadata and controls
49 lines (41 loc) · 825 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Created by 20281 on 2023/1/12.
//
#include "ProgressBar.h"
//using namespace std;
/**
* 进度条类
* 用于血条,饱食度条等等
*/
ProgressBar::ProgressBar(double mv, double v) {
this->maxValue = mv;
this->value = v;
}
/**
* 进度条更改值操作
* 能够防止加爆了,减成负数了等情况
* @param d
*/
void ProgressBar::change(double d) {
this->value += d;
if (this->value > this->maxValue) {
this->value = this->maxValue;
}
if (this->value < 0) {
this->value = 0;
}
}
/**
* 直接让进度条里的值顶满
* 用于:血条补满
*/
void ProgressBar::setMax() {
this->value = this->maxValue;
}
/**
* 当前条是不是满了的状态
* @return
*/
bool ProgressBar::isMax() const {
return this->value >= this->maxValue;
}