Hi
Im beginner in SFML and i have one problem.
I wrote my own OnSpriteClick method witch works great untill i used it in if statement .
the second IsSpiritClicked (Pauza.IsSpiteClicked) trigger whenever i cover spirit with mouse.
if (Start.IsSpiteClicked(Window, Start.Sprite, Event))
{
bool end = false;
while (end != true)
{
if (Pauza.IsSpiteClicked(Window, Pauza.Sprite, Event))
end = true;
/* OTHER CODE */
}
}
And this is the method
bool Buttom::IsSpiteClicked(sf::RenderWindow &x, sf::Sprite &y , sf::Event &event)
{
sf::Vector2f mouse(sf::Mouse::getPosition(x));
if (event.type == sf::Event::MouseButtonPressed && event.key.code == sf::Mouse::Left && y.getGlobalBounds().contains(mouse))
return true;
else return false;
}
event is a sf::Event
Window is a sf::RenderWindow
Start is my own class Button