I'm trying to make a button, everything is working fine, except for one thing.
If I try to move or scale the button the bounds don't change, and obviously the mouseclick still gets detected at the initial position.
This is my button update code:
mCDTime = mCDClock.getElapsedTime();
if (mEnabled && mCDTime > sf::Time(sf::seconds(0.30f)))
{
auto spriteBounds = mSprite.getLocalBounds();
auto mousePosition = sf::Mouse::getPosition(*mWindowPtr);
if (spriteBounds.contains(static_cast<sf::Vector2f>(mousePosition)) && sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
{
OnClick();
mCDClock.restart();
}
mText.setPosition(mSprite.getPosition());
mText.setScale(mSprite.getScale());
mText.setRotation(mSprite.getRotation());
}