I have two circle shapes on the screen, and when the left mouse button is held down, and the mouse cursor is over one of the circles, it should "pick it up" and the circle follows the mouse cursor until the left mouse button is released.
There is an issue when I pick up one of the circles, and move it over the other, because then this causes the second shape to be picked up also and I cannot separate them since they are on top of each other.
Here is my input code for the circles:
if ( (sf::Mouse::IsButtonPressed(sf::Mouse::Button::Left)) && (sf::Mouse::GetPosition(App).x > circle.GetPosition().x - circle.GetRadius())
&& (sf::Mouse::GetPosition(App).x < circle.GetPosition().x + circle.GetRadius())
&& (sf::Mouse::GetPosition(App).y > circle.GetPosition().y - circle.GetRadius())
&& (sf::Mouse::GetPosition(App).y < circle.GetPosition().y + circle.GetRadius()) )
{
circle.SetPosition(sf::Mouse::GetPosition(App).x, sf::Mouse::GetPosition(App).y);
}
This picks up the circle fine but causes the issue mentioned above
I did try to add a bool so it would only pick it up if it didn't have one picked up already, and here is the code for that:
bool nodeGrabbed = false;
if ( (nodeGrabbed == false) && (sf::Mouse::IsButtonPressed(sf::Mouse::Button::Left)) && (sf::Mouse::GetPosition(App).x > circle.GetPosition().x - circle.GetRadius())
&& (sf::Mouse::GetPosition(App).x < circle.GetPosition().x + circle.GetRadius())
&& (sf::Mouse::GetPosition(App).y > circle.GetPosition().y - circle.GetRadius())
&& (sf::Mouse::GetPosition(App).y < circle.GetPosition().y + circle.GetRadius()) )
{
nodeGrabbed = true;
circle.SetPosition(sf::Mouse::GetPosition(App).x, sf::Mouse::GetPosition(App).y);
}
else
{
nodeGrabbed = false;
}
But this still did not work
Maybe I should mention that each shape is in a class and the two different shapes I have created are in a vector, and I go through this vector to check for user input, so maybe this has something to do with it as it just gets the input for both at the same time?
Any help would be appreciated