#pragma once
#include <SFML/Graphics.hpp>
class RectangleWText
{
private:
sf::RectangleShape shape;
sf::Font font;
sf::Text label(std::string&);
public:
RectangleWText(const sf::Vector2f& size, const sf::Vector2f& position, const
std::string& text = "", const std::string& fontPath = "fonts/verdana.ttf") {
if (!font.openFromFile("verdana.ttf"))
{
std::cerr << "Error loading font" << std::endl;
}
sf::Font font(fontPath);
sf::Text label(font);
shape.setSize(size);
shape.setPosition(position);
label.setString(text);
label.setPosition(position);
}
void draw(sf::RenderWindow& window) {
window.draw(shape);
window.draw(label);
}
};
SFML 3 changed the way you initiate text and it is killing me since I can't draw it in my draw function now, I am new to SFML please someone help me.