Good Morning
Does anyone of you know how to move an object with the mouse. So if I go to the left with the mouse, the object also goes to the left.
With kind regards
Good Morning
Does anyone of you know how to move an object with the mouse. So if I go to the left with the mouse, the object also goes to the left.
With kind regards
Hello!
It’s always better when you post your code (so far you got) and explain more what you want to achieve.
But here is an example based on your (very brief) explanation.
Warm regards,
Chrisir
PVector player;
void setup() {
size(900, 900);
player = new PVector(width/2, height/2);
}
void draw() {
background(0);
ellipse(player.x, player.y, 9, 9);
}
void mouseMoved() {
// check x
if (mouseX<pmouseX)
player.x--;
else if (mouseX>pmouseX)
player.x++;
// -------
// check y
if (mouseY<pmouseY)
player.y--;
else if (mouseY>pmouseY)
player.y++;
}