Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML 1.6, ConvertCoords does not work properly  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

Mitmischer 1703

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML 1.6, ConvertCoords does not work properly
« 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:

Code: [Select]
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:

Code: [Select]
// 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:

Code: [Select]
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

Code: [Select]
img->SetPosition(X,Y);

What do I do wrong?

 

anything