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