why are the coordinates for the mouse not changing?

edited October 2013 in Questions about Code
PFont a;
String coordinates = "(" + mouseX + "," + mouseY + ")";

void setup() {
  size(500, 350);
  a = createFont("Arial", 20, true);
}

void draw() {
  fill(0);
  textFont(a);   
  if (mousePressed) {
    text(coordinates, mouseX, mouseY);
  }
  if (keyPressed) {
    if (key == ' ') {
      background(204);
    }
  }
}

Answers

  • edited October 2013 Answer ✓

    because the coordinates String gets set ONCE, at the top there. you need to change it every loop if you want to see it change.

    change line 13 to this: text("(" + mouseX + "," + mouseY + ")", mouseX, mouseY);

Sign In or Register to comment.