-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextbox.cpp
32 lines (32 loc) · 890 Bytes
/
Textbox.cpp
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
#include <SFML/Graphics.hpp>
#include "Textbox.h"
#include <iostream>
Textbox::Textbox(const sf::Vector2f &position, float width, float height, float fontSize, float letterSpacing, std::string text)
: m_width(width), m_height(height), m_position(position), m_fontSize(fontSize)
{
if(!m_font.loadFromFile("../assets/fonts/ArcadeClassic.ttf"))
{
std::cout<<"Couldn't load font\n";
}
m_text=sf::Text(text, m_font);
m_text.setFont(m_font);
m_text.setPosition(position);
m_text.setCharacterSize(m_fontSize);
m_text.setLetterSpacing(letterSpacing);
}
sf::Text Textbox::getText()
{
return m_text;
}
void Textbox::setText(const std::string &text)
{
m_text.setString(text);
}
void Textbox::render(sf::RenderWindow &renderWindow)
{
renderWindow.draw(m_text);
}
void Textbox::setColor(const sf::Color &color)
{
m_text.setFillColor(color);
}