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

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

fixed no worries

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.