callback.mouse should return sf::Vector2u
« on: 01 June 2013, 11:49:54 »
IMHO it would be better if it returns sf::Vector2u, because then we'll be able to simply do this:
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

  • *****
  • 1151
    • View Profile
    • Texus's Blog
Re: callback.mouse should return sf::Vector2u
« Reply #1 on: 01 June 2013, 13:24:29 »
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.
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.

Re: callback.mouse should return sf::Vector2u
« Reply #2 on: 01 June 2013, 13:31:54 »
Okay, thanks. :)