Dear all,
i am trying to get my sprite to be dragged around the screen by clicking the mouse, i can get it to attach to the mouse but cannot get it to unattach itself, i coded the if not mouse click then set mouse attach to false but it does not seem to work.
Could anybody tell me where i am going wrong??
if(myApp.GetInput().IsMouseButtonDown(sf::Mouse::Left) && !mouseAttached && gameState==playing) //if the left mouse button is pressed and it is not currently attached
{
if(dist(widthNormalise(myApp.GetInput().GetMouseX()),heightNormalise(myApp.GetInput().GetMouseY()),g1.getPosX(),g1.getPosY())< g1.getRadius()) //if the mouse is over or touching the green draught
{
mouseAttached=true;
pMseTacheddraught=&g1;
}
if(!myApp.GetInput().IsMouseButtonDown(sf::Mouse::Left)) //if the mouse is not being pressed
{
mouseAttached=false;
pMseTacheddraught=0;
}
}
}
}