Hello everyone!
I am trying to handle clicks on non-transparent part of
sf::Sprite. I've created texture in
.png format which contains transparent background. I handle clicks with following code:
zones = ...;
sf::Sprite someSprite = ...;
MouseState mState = InputManager::I().GetMouseState();
for (int i = 0, size = zones.size(); i < size; ++i)
{
if (mState.LeftButtonClicked && someSprite.getGlobalBounds().contains(mState.PositionX, mState.PositionY))
{
// ... some code
}
// ... more code
}
Mouse state updates and clicks are handled properly, however clicks on the transparent part of the
sf::Sprite are detected as inside sprite (which is correct I suppose, since getGlobalBounds returns (bounding?) rectangle).
I need to handle clicks only on visible part of the sprite.
Does SFML support such thing? If so, how to achieve that?
Do I have to handle this myself? If so, how to achieve that? (Not asking for actual code, but tips/algorithms/etc).
See attachment for visualisation and example texture file.