Hello guys, it's my first post here. I started to play with SFML and I have quite strange problem. I want to write letters '1' or '0' in my board. I want it to show immediately after I press 1 or 0 but can't really do it well. Here's my void. It should draw 1 or 0 in a position immediately after I press1 or 0 and it actually does, but after I want to print another number the previous one is getting hidden.
void tablica::rysowanie_cyfr(sf::RenderWindow & window)
{
int a = 50;
int b = 50;
sf::Event event;
bool wait = true;
for (int i = 0; i<4; i++) {
for (int j = 0; j<4; j++) {
sf::Text *text = new sf::Text;
text = set_properties(window);
while (wait) {
while (window.pollEvent(event)) {
if (event.type == sf::Event::KeyReleased) {
if (event.key.code == sf::Keyboard::Num1) {
text->setPosition(a, b);
text->setString("1");
wait = false;
window.draw(*text);
}
else if (event.key.code == sf::Keyboard::Num0)
{
text->setPosition(a, b);
text->setString("0");
wait = false;
window.draw(*text);
}
}
}
}
delete text;
wait = true;
a += 100;
window.display();
}b += 100; a = 50;
}
}
It is summoned in a main loop like this
if (wait == true) {
tabela.rysowanie_cyfr(window);
}
wait is set at false and when i press a button I set wait as true.
Please, help me
Also sorry for my english it's not my native language. If you have problems with understanding my problem I can explain it futher.