Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - togtja

Pages: [1]
1
Graphics / Re: Multiple Mouse clicks
« on: February 09, 2019, 09:17:12 am »

 
Of course, once you set onMouse to true, you enter the 2nd if. Put your second if inside the else of the first one.
I feel pretty stupid now. Anyways Thanks a lot for the help

2
Graphics / Multiple Mouse clicks
« on: February 09, 2019, 08:39:22 am »
So i have a bool that checks if you have "picked up", then onMouse should be true, if you click again (aka drop it), then it will be false. However, when I click it turns true, then back to false again
sf::RenderWindow window(sf::VideoMode(10,10), "Some Game");
window.setKeyRepeatEnabled(false);
bool onMouse = false;
while (window.isOpen()) {
        sf::Event event;
        while (window.pollEvent(event)) {
                if (event.type == sf::Event::Closed)
                        window.close();
                if (event.type == event.MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left && !onMouse) {
                        std::cout << "on Mouse True/Picked up\n";
                        onMouse = true;
                }

                if (event.type == event.MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left && onMouse) {
                        std::cout << "on Mouse False/Dropped\n";
                        onMouse = false;
                }
        }
}
 
I have looked for other similar post, but non have helped my case

Pages: [1]