while (window.isOpen())
{
//Processes events
sf::Event event;
//Fills Event with data
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
window.clear();
window.draw(bgs);
window.display();
xTurn();
}
void xTurn()
{
bool xturn = true;
while(xturn)
{
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
sf::Vector2i mousePosition = sf::Mouse::getPosition(window);
if((mousePosition.x < 200 && mousePosition.y < 200)
&& sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
X.setPosition(25, 20);
window.draw(X);
std::cout << "hi";
xturn = false;
}
}
}
There's part of my main method and my whole xTurn code. Essentially when you left click, I want the sprite X to be printed. Also, that buttonispressed seems to activate multiple times (hi prints out 30+ times as opposed to just once).
How do I go about doing this?
Thanks.