callback.mouse should return sf::Vector2u

Started by china92, 01 June 2013, 11:49:54

china92

IMHO it would be better if it returns sf::Vector2u, because then we'll be able to simply do this:
Code (cpp) Select
object.setPosition(object2.getPosition() + callback.mouse);

I mean - operators would work, and this way is much more convenient.

Here is an example from my tower defense: I'm putting a callback at some object, and after this I want to put turret in a place where mouse cursor occur. Since callback.mouse returns only local bounds from the object where callback was sent, I have to add some coordinates to make sure that turret will be in a correct place.

What do you think, texus?

texus

The callback.mouse can already be casted to sf::Vector2i, so you could write sf::Vector2i(callback.mouse) if you want to make it a vector.

But this still wouldn't work because there is no + operator between Vector2f (which getPosition returns) and a Vector2i.

So unless I would make it a Vector2f directly (which I don't want because it is a pixel position and shouldn't be a float value), you would have to make a cast.
Code (cpp) Select
sf::Vector2f mousePos = sf::Vector2f(sf::Vector2i(callback.mouse));

I will probably make it so that callback.mouse is a Vector2i so that you would only have to cast to Vector2f, but I'll do that in the latest version when I have time so you'll have to keep the extra cast for now.