Hi guys, I tried to render a text and I got this error: sf::RenderTarget::draw': no overloaded function takes 0 arguments.
This is the code:
the class:
class menu
{
public:
void draw_text();
void move_up();
void move_down();
private:
sf::Text text;
sf::Font font;
};
menu cpp:
void menu::draw_text()
{
try {
if (!font.loadFromFile("champ.ttf"))
throw font.loadFromFile("champ.ttf");
}
catch (...) {
cout << "Error! Missing font!";
}
text.setFont(font);
text.setFillColor(sf::Color::Red);
text.setString("Hello there");
text.setCharacterSize(30);
}
the main cpp:
int main()
{
menu menuObj;
sf::RenderWindow window(sf::VideoMode(1920, 1080), "SpaceShooter");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw();
menuObj.draw_text();
window.display();
}
return 0;
}
I didn't finish the text code but I tried it to see if it works, to see if at least the text appears on screen.I don't know if you will understand the code but I hope someone can help me.