I am using a switch to check the position of the mouse click and then display the sprite at the clicked location.
I am using this. But the sprite comes for one frame and then goes away. also i have placed the switch inside the main game loop. So is there a way I can fix the Sprite once it is spawned so that it doesnt despawn. Or is there a way so that i can place my sprite automatically Inside the rectangle and also check if cell_1 == cell_2 == cell_3 so the player wins
case Event::MouseButtonPressed:
if (event.mouseButton.button == Mouse::Left) {
if (Cell_1.getGlobalBounds().contains(window.mapPixelToCoords(sf::Mouse::getPosition(window)))) {
cout << "Cell 1" << endl;
window.draw(sprite);
sprite.setPosition(Vector2f(125.f, cell_height));
window.display();
}