SFML community forums

Help => Graphics => Topic started by: BlackPhoenix on July 30, 2010, 09:44:46 pm

Title: Grabbing a shape with the mouse
Post by: BlackPhoenix on July 30, 2010, 09:44:46 pm
Hello,

The title pretty much says it all. I want to grab a small circle that I draw with the mouse, and move it. Like drag and drop.

Also I wonder why the code below doesn't work

Code: [Select]
while(Input.IsMouseButtonDown(sf::Mouse::Left))
            selector.SetPosition(Input.GetMouseX(),Input.GetMouseY());


Thanks
Title: Re: Grabbing a shape with the mouse
Post by: nightlet on August 17, 2010, 01:14:26 pm
Quote from: "BlackPhoenix"
Code: [Select]
while(Input.IsMouseButtonDown(sf::Mouse::Left))
            selector.SetPosition(Input.GetMouseX(),Input.GetMouseY());


I'd at least change the while to an if, otherwise it won't do anything else if it's true- even render.
Title: Grabbing a shape with the mouse
Post by: Finn on August 17, 2010, 05:15:07 pm
And further you could first check, if the mouse is over the circle before moving it ;)