'how to erase text from window
I wanted to make some clicker, and everything has gone easily but, I can't erase text from window. By I can't erase I mean that if i draw some text(int converted to string to be specific). "123" for example. And I want to change that "123" text to new one, let's say "124", the old text is still visible on the window, and I don't know how to erase it. And yes, I've looked for how to do that on internet, but i only found .erase() class and remove_last_char() that doesn't work for me.
I am using the string stream to convert int to string. And i don't think that the code that i am using is necessary here.
Edit - Here's my code(And sorry if i am doing something wrong but i am new to stack overflow):
stringstream scash;
Text text;
text.setCharacterSize(16);
text.setFillColor(Color::White);
text.setPosition(0, 50);
text.setFont(font);`
while (window.isOpen())
{
text.setString(scash.str());
window.clear();
button.setPosition(W_width / 2, W_height / 2);
window.draw(button);
window.draw(text);
if(//button/mouse collision check here)
{
if(Mouse::isButtonPressed(Mouse::Left))
{
cash = cash + 1;
scash << cash;
}
}
window.display();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
