954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Mouse dragging code

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;
}
}
}
}]

benny2010
Newbie Poster
11 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

The brackets are there because i thought that it would put the code on the page properly....obviously not sorry

benny2010
Newbie Poster
11 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

fixed no worries

benny2010
Newbie Poster
11 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: