I am a beginner and finding a problem. I wrote the following code and had error message “a cannot be resolved to a variable”. The rectangle appears fine with numbers but will not accept a declared integer.
void setup () {
size (500,400);
int a = 100;
}
void draw() {
rect(a, 100, 200, 200);
}
The problem here is that since you’ve declared a inside the setup() function, it’s only available inside the setup() function. If you want variables to be available inside multiple functions, you have to declare them outside the functions. Something like this:
int a;
void setup () {
size (500,400);
a = 100;
}
void draw(){
rect(a, 100, 200, 200);
}