-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathOStringText.cpp
More file actions
45 lines (33 loc) · 1.23 KB
/
OStringText.cpp
File metadata and controls
45 lines (33 loc) · 1.23 KB
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
#include "OStringText.h"
OStringText::OStringText(float posX, float posY, unsigned int characterSize, std::string fontFile, sf::Color textColor) {
textFont.loadFromFile(fontFile);
this->text.setFont(textFont);
this->text.setPosition(posX, posY);
this->characterSize = characterSize;
this->text.setFillColor(textColor);
}
void OStringText::updateOText(std::string text, int variable) {
this->text.setCharacterSize(characterSize);
this->text.setOrigin(this->text.getGlobalBounds().width / 2, this->text.getGlobalBounds().height / 2);
this->text.setString(text);
ssText.str("");
ssText << text << variable;
this->text.setString(ssText.str());
}
void OStringText::renderTo(sf::RenderWindow& window) {
window.draw(text);
}
void OStringText::changePosition(float posX, float posY) {
this->text.setPosition(posX, posY);
}
void OStringText::changeColor(sf::Color textColor) {
this->text.setFillColor(textColor);
}
void OStringText::changeCharacterSize(unsigned int characterSize) {
this->characterSize = characterSize;
this->text.setCharacterSize(this->characterSize);
}
void OStringText::changeFont(std::string fontFile) {
textFont.loadFromFile(fontFile);
this->text.setFont(textFont);
}