Xeverous Xeverous - 8 months ago 52
C++ Question

No know conversion for argument 1 from sf::Vector2i to const sf::Vector2i<float>&

I am trying to make simple button using SFML library. The button is supposed to change it's text color when I place mouse on it.

void Button::updateColor(sf::Vector2i MousePos)
if(sprite.getGlobalBounds().contains(MousePos)) //here is the problem

the .contains() function expects

const vector2<T>&

the exact error is:

no known conversion for argument 1 from 'sf::Vector2i {aka sf::Vector2<int>}' to 'const sf::Vector2<float>&'

I have tried to change

void Button::updateColor(sf::Vector2i MousePos)


void Button::updateColor(const sf::Vector2i& MousePos)

this removed the problem with constness, however I still dont know what to do with invalid reference. I dont know how to pass mouse position correctly.

Thanks for help.


The error message is clear: you're trying to pass a Vector2<int> instead of the expected Vector2<float>.

Since float != int, this isn't going to work. Modify your input variable.