Hey
I have a slight issue im stuck with .... i have a button which when the mouse hovers over the button the image changes - this works perfectly fine.
How ever if i add a button pressed event the button no longer thinks the mouse is hovering over it. I'm not sure why! It seems i can't do both events at the same time...
This is my event loop in my main loop:
bool click = false;
int mouseX;
int mouseY;
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed) {
window.close();
}else{
if(event.type == sf::Event::MouseButtonPressed){
click = true;
}
if(event.type == sf::Event::MouseMoved){
mouseX = event.mouseMove.x;
mouseY = event.mouseMove.y;
}
}
}
// Clear screen
window.clear();
btn_quit.RenderBttn(window,mouseX,mouseY,button,button_on,click);
window.display();
Basically if i do a mouseButtonPressed event - the mouse position seems to be lost. Any reason this could happen ?
EDIT: i did a quick check and what occurs. When i do a mouseButtonPressed event, the mouse position becomes 0 : 0, i don't know why how ever.