5
« on: April 18, 2011, 12:51:25 pm »
Hi there!
i have a problem using the ConvertCoords-method of window.
I'll first describe, what I want to do. When the user clicks, I want a new circle to appear on the screen. I'm performing a scroll when the mouse touches a border, so I the mouse coordinates themselves wouldn't do anymore. So I found the ConvertCoords-method and tried to determine the real position of a new shape like this:
sf::Vector2f convertedCoords = App->ConvertCoords(static_cast<unsigned int>(x),static_cast<unsigned int>(y));
x and y are the last known coordinates of the mouse, I determine them in the message loop, like this:
// left mouse button released
if (Event.Type = sf::Event::MouseMoved)
{
// Save mouse position
x = Event.MouseMove.X;
y = Event.MouseMove.Y;
}
Then I initialize a new shape with the newly calculated coordinated and display it. But it does only seldom work, as soon as I'm close to any border(around 200px distance), x is simply ignored. I'm working on uploading an executable.
My shape is initialized like this:
new sf::Shape(sf::Shape::Circle(50,50,50, sf::Color(0,25,60), 6, sf::Color(255,23,65)));
Later I change the coordinates to x and y from above via
img->SetPosition(X,Y);
What do I do wrong?