There seems to be something strange going on when it comed to reacting to mouse clicks. I have some buttons (images, no gui) where the user can click and everything works until the 3rd click (99.9% of the time). After that you randomly have to click the button once/twice before anything happens. If I run my game with visual studios 2008 pro (start debugging) this problem never occurs but if I close visual studios and double click the executable it does. Today I discovered that the problem occures if I don't move the mouse at all during the first 3 clicks, If I move it before I click the 3rd time it works. :?
I have tried it on 3 computers, my laptop gets the behavior described above and the other two get the problem as well, but not necessarily on the 3rd click.
I have designed my game in two completely different ways (exept for the event-loop) but the problem shows up for both. I have tried events and inputs for mouse clicks but both have the same problem. I'm linking with the static libraries.
This is the event-loop:
sf::Event eEvent;
while(renderer::getInstance()->getRenderWindow()->GetEvent(eEvent))
{
if(eEvent.Type == sf::Event::KeyPressed && eEvent.Key.Code == sf::Key::Escape)
exit(EXIT_SUCCESS);
else if(eEvent.Type == sf::Event::MouseButtonPressed && eEvent.MouseButton.Button == sf::Mouse::Left)
{
int mouseX = renderer::getInstance()->getRenderWindow()->GetInput().GetMouseX();
int mouseY = renderer::getInstance()->getRenderWindow()->GetInput().GetMouseY();
int hit = -1;
for(int i = 0; i < 5; i++)
{
if(v_iClickables[i].Contains(mouseX, mouseY)) //check clickable regions (sf::IntRect)
{
hit = i;
break;
}
}
//if a button was pressed, act accordingly
if(hit == 0)
exit(EXIT_SUCCESS);
else if(hit == 1)
; //to be implemented
else if(hit == 2)
{
if(!bIsSpinning) //if wheels are not spinning, start spinning
{
for(int i = 0; i < signed(v_iWheelsLeftToSpin.size()); i++)
v_iWheelsLeftToSpin[i] = sf::Randomizer::Random(5, 19);
v_iWheelsLeftToSpin[0] += 10;
bIsSpinning = true;
}
}
else if(hit == 3)
; //to be implemented
else if(hit == 4)
; //to be implemented
}
}
I should be able to put together an example if you want to see the problem in action. I have no idea why the problem only occurs if you run the executable and not when you are debugging it with visual studio :?