Need help getting mouseX and mouseY location when you press the mouse
in
Programming Questions
•
1 year ago
- int x = mouseX;
- int y = mouseY;
- string x1 = str(x);
string y1 = str(y); - void setup(){
- size(700,500);
- }
- void draw(){
- //gives the location of the mouse on the top left corner
- fill(#000000); //black
- rect(700-60,10,55,30);
- String mouseLocation = "" + mouseX + ", " + mouseY;
- fill(#FFFF00); //yellow
- text(mouseLocation, 700-55,30);
- //evaluates to determine if mouse is pressed. If true, then it prints out the mouseX and mouseY location.
- if(mousePressed == true){
- print(x1+y1);
- }
- }
I essentially want to have a variable that stores the x and y mouse location when it's pressed so I can use it later. But i'm not sure why my logic is wrong. Can somebody help me fix it?
1