moving image mouse pressed
in
Programming Questions
•
9 months ago
hello
i'm having problem with moving image to different location when you press on it with mouse. The program is working on the whole background but i want that picture would move when only when i click on it and drag it around on background not if i click outside the image. I'm copying methodes that i used.
Hope someone can give me an advise.
public void mousePressed()
{
if(overImage){
locked=true;
}else{
locked=false;
}
offX=mouseX-mX;
offY=mouseY-mY;
}
public void mouseDragged(){
if(locked){
mX=mouseX-offX;
mY=mouseY-offY;
}
}
public void mouseReleased(){
locked=false;
}
i'm having problem with moving image to different location when you press on it with mouse. The program is working on the whole background but i want that picture would move when only when i click on it and drag it around on background not if i click outside the image. I'm copying methodes that i used.
Hope someone can give me an advise.
public void mousePressed()
{
if(overImage){
locked=true;
}else{
locked=false;
}
offX=mouseX-mX;
offY=mouseY-mY;
}
public void mouseDragged(){
if(locked){
mX=mouseX-offX;
mY=mouseY-offY;
}
}
public void mouseReleased(){
locked=false;
}
1