Hallo Leute,
zurzeit programmiere ich (im Team) ein Spiel. Als Startmenü brauchen wir Buttons, um die Gamestates zu wechseln. Als Beschriftung der Buttons möchten wir ein anderes Font verwenden, als das, welches wir für alle anderen Texte verwenden. Hier der Codeausschnitt:
.hpp:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Button : protected Gui
{
public:
// ...
private:
// ...
sf::Font m_Font;
sf::Text txtStartButton;
sf::Text txtOptionButton;
sf::Text txtExitButton;
};
|
.cpp:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// ...
void Button::loadTextes()
{
if (!m_Font.loadFromFile("assets/fonts/sserife.fon"))
throw std::runtime_error("Konnte das Font nicht laden.");
else
setTextes();
}
void Button::setTextes()
{
txtStartButton.setFont(m_Font);
txtOptionButton.setFont(m_Font);
txtExitButton.setFont(m_Font);
txtStartButton.setCharacterSize(10);
txtOptionButton.setCharacterSize(10);
txtExitButton.setCharacterSize(10);
}
// ...
|
Wenn ich es ausführe, dann bekomme ich den std::runtime_error. Was habe ich falsch gemacht?
Vielen Dank im Voraus
PS: Ein Screenshot von den Ordner ist im Anhang