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

Edited 3 Years Ago by mike_2000_17: Fixed formatting

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

This question has already been answered. Start a new discussion instead.