-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckBox.cpp
More file actions
31 lines (24 loc) · 714 Bytes
/
Copy pathCheckBox.cpp
File metadata and controls
31 lines (24 loc) · 714 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
#include "CheckBox.h"
Image CheckBox::checked("Images/chkBoxChecked.png");
Image CheckBox::unchecked("Images/chkBoxUnchecked.png");
CheckBox::CheckBox(StartEngine *engine, Vector2i position, bool isAlphaBlended)
: GuiComponent(engine, position, checked.getWidth(), checked.getHeight(), isAlphaBlended) {
isChecked = false;
}
bool CheckBox::getIsChecked() {
return isChecked;
}
void CheckBox::update(bool wasMouseLeftToggled) {
if (wasMouseLeftToggled && engine->isCursorInsideBB(&bBox)) {
isChecked ^= true;
}
}
void CheckBox::draw() {
Image *sprite;
if (isChecked) {
sprite = &checked;
} else {
sprite = &unchecked;
}
engine->draw(sprite, 0, false, false, false, position.x, position.y);
}