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

Author Topic: Grabbing a shape with the mouse  (Read 2306 times)

0 Members and 1 Guest are viewing this topic.

BlackPhoenix

  • Newbie
  • *
  • Posts: 7
    • View Profile
Grabbing a shape with the mouse
« 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

nightlet

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Grabbing a shape with the mouse
« Reply #1 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.

Finn

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
Grabbing a shape with the mouse
« Reply #2 on: August 17, 2010, 05:15:07 pm »
And further you could first check, if the mouse is over the circle before moving it ;)