Hi, I am trying to be able to change where the mouse cursor is so it would be easier to see if I am hovering over one of my objects without looking at every pixel by pixel.
Thanks in advance,
Eric
Hi, I am trying to be able to change where the mouse cursor is so it would be easier to see if I am hovering over one of my objects without looking at every pixel by pixel.
Thanks in advance,
Eric
good question,
may i fill it with a example:
// https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580?u=kll
// or ? does a moved object know where it is ?
MySquare here;
//________________________________________________________
public class MySquare {
int posX, posY, wide;
public MySquare(int posX, int posY, int wide ) {
this.posX = posX;
this.posY = posY;
this.wide = wide;
}
public void draw() {
stroke(0, 200, 0);
if (over(mouseX, mouseY)) fill(200, 200, 200);
else fill(0, 0, 0);
rect(posX, posY, wide, wide);
}
boolean over(int mx, int my) {
if ((mx > (posX)) & (mx < (posX+ wide))) {
if ((my > (posY)) & (my < (posY+ wide))) {
return true;
}
}
return false;
}
}
//________________________________________________________
void setup() {
size(500, 500);
here = new MySquare(10, 10, 100); // MySquare(x,y,wide);
}
//________________________________________________________
void draw() {
background(200, 200, 0);
noStroke();
fill(150, 150, 150);
rect(10, 10, 100, 100); // mouse dummy
pushMatrix();
translate(width/2, height/2);
rotate(PI/4);
stroke(200, 0, 0);
line(-200, 0, 200, 0);
stroke(0, 0, 200);
line(0, -200, 0, 200);
here.draw();
popMatrix();
}