mousePressed, separating LEFT and RIGHT.
in
Programming Questions
•
3 years ago
I have 2 .svg objects loaded up into a design, one on the left and one on the right. I'm trying to make it so that by LEFT clicking, I can drag on around the left object by itself, and same for the right. Currently, left clicking controls both simultaneously, and same with right clicking. I'm sure there's a way to get around this, but I'm not sure how.
Thanks for the help!
Here's the portion of my code that I'm trying to deal with:
void draw()
{
background(255);
//eyebrow_left shape
PShape el;
el = loadShape("eyebrow_left.svg");
smooth();
shape(el,currX,currY,121,100);
//end eyebrow_left shape
//eyebrow_right shape
PShape er;
er = loadShape("eyebrow_right.svg");
smooth();
shape(er,currX,currY,113,99);
//end eyebrow_right shape
currY = constrain(currY, -15, 0);
if (currY<0)
{
currY+=1;
}
if (mousePressed == true)
{
if (mouseButton == LEFT)
{
float targetY = (mouseY-225);
float dy = (targetY - currY);
currY += dy*easing;
//eyebrow_left shape
smooth();
shape(el,currX,currY,640,480);
//end eyebrow_left shape
}
else if (mouseButton == RIGHT)
{
float targetY = (mouseY-225);
float dy = (targetY - currY);
currY += dy*easing;
//eyebrow_right shape
smooth();
shape(er,currX,currY,640,480);
//end eyebrow_right shape
}
}
}
1