Learning Processing
in
Programming Questions
•
1 year ago
Hello.
I have recently stumbled across processing and have decided to try learn it myself as a first computer language.
What I am currently trying to do is simply have a square and circle appear on a mousePressed but not before. Then upon dragging the mouse (with the square and circle intact) have the circle and only the circle disappear on a mouseRelease, leaving the square. Im trying to sort of replicate a 'drag and drop' action.
Not sure if I should be using all three mouse variables (pressed, drag, released).
Also how do I start the program without the square/circle showing at the start?
For the circle to dissapear I am simply moving it off screen but im sure there is a better way - maybe with booleans or some condition.
Any help or advice is appreciated.
Thankyou.
- int circlelocX, circlelocY;
int rectlocX, rectlocY;
boolean release = false;
boolean start = false; - void setup() {
size(350,500);
rectMode(CENTER);
ellipseMode(CENTER);
smooth();
frameRate(60);
}
void draw() {
background(255);
// should use if statement here for start condition???
noFill();
fill(255,0,0);
ellipse(circlelocX,circlelocY,75,100);
noFill();
rect(rectlocX, rectlocY, 75, 100);
}
void mousePressed() {
rectlocX=mouseX;
rectlocY=mouseY;
circlelocX=mouseX;
circlelocY=mouseY;
} - void mouseDragged() {
rectlocX=mouseX;
rectlocY=mouseY;
circlelocX=mouseX;
circlelocY=mouseY;
} - void mouseReleased() {
circlelocX=-1000;
} - //release = true; //How to make the oval disapear only. Leaving the square.
1