Hi,
I have a custom entity class, like in the example, which has a simple bounding box for mouse click detection method -
bool Entity::isPointInside(sf::Vector2i input)
{
if(input.x > getPosition().x && input.x < getPosition().x+Texture.getSize().x &&
input.y > getPosition().y && input.y < getPosition().y+Texture.getSize().y)
{
return true;
}
return false;
}
This is working fine. I am using a View to zoom in and zoom out the viewport. The problem comes here, When the view is (0,0,1,1), everything works fine, but when I zoom out the view, the bounding box of the entity node still remains the same. So, changing the world coordinate to pixel does not work here.
Is there a way to get the position of the Enitity after zoom out, relative to the view rectangle area? So that I can re-update the bounding box which is a shape rectangle or there is any other way to detect the mouse click after zoom out?
Thank you.
The code you just showed looks correct, so could you provide a complete and minimal example? (ie, one we can actually run and see fail for ourselves) Also you forgot to tell us how this current code is "not working," so we still can't even guess what the problem might be.
Then I just check the MousePos, it is inside or not.
What does this mean? You shouldn't need to do another check after the two you just showed.
P.S. contains() already returns a bool, so isPointInside() should just be
returns boundRect.contains(input);